Modify

#508 closed Feature Request (Completed)

Static variables

Reported by: cbruce Owned by: Nutster
Milestone: 3.3.1.4 Component: AutoIt
Version: Severity: Blocking
Keywords: static variable scope Cc:

Description

AutoIt is a wonderful product folks - thank you so much...

It would be nice to see Static variables added to AutoIt. A Static variables is defined as a variable whose scope is local to a function, but that maintains its value between invocations of the function that the Static variable resides in.

Currently, I have to use Global variables to achieve this effect. This creates a greater opportunity for introducing bugs in a program. [Man, does it ever - I just bit myself again - 3 hours of debugging - the impetus for submitting this feature request]. With Static variables, there is less dependence on the programmer's memory.

I love, and need, Global variables; but the addition of Static variables would make me a more productive programmer in AutoIt.

Respectfully,
Bruce Huber

Attachments (0)

Change History (11)

comment:1 by Gary, on Aug 8, 2008 at 6:31:55 PM

look at "Global Const"

comment:2 by Valik, on Aug 8, 2008 at 7:45:41 PM

Resolution: Rejected
Status: newclosed

Gary, the value needs to be mutable. For example, a counter for the number of times a function is called could be implemented as a static variable (or global, obviously).

cbruce, much like many other things that some other languages offer as "features", you can do this yourself. It just requires you to develop your own rigid naming system to prevent collisions. For example, a name in the form "$g_vStatic_MyVar" will help reduce collisions. Adding the function name in can help disambiguate names further at the cost of increased length in the name.

Closing as rejected.

comment:3 by Valik, on Aug 8, 2008 at 7:50:19 PM

Err, that should have been two $[underscore][underscore]g. Apparently I accidentally triggered the wiki's underline thing.

comment:4 by TicketCleanup, on Aug 8, 2008 at 8:00:19 PM

Version: 3.2.12.1

Automatic ticket cleanup.

comment:5 by Gary, on Aug 8, 2008 at 8:13:21 PM

Valik your correct, I was thinking one thing and posted along another thought line.

An example of what Valik is stating can be found in UDFGlobalID.au3 ( $_UDF_GlobalIDs_Used) where I named it so it shouldn't be reused anywhere.

The above variable is an array but you should get the drift of the idea.

in reply to:  5 comment:6 by cbruce, on Aug 8, 2008 at 10:00:39 PM

Like I say, it's more work for the programmer - but an absolutely pragmatic approach. I'll start using this type of naming convention in AutoIt.

Thanks folks,
Bruce

comment:7 by Nutster, on Sep 17, 2009 at 3:17:06 AM

Milestone: Future Release
Resolution: Rejected
Status: closedreopened

I'll start working on this.

comment:8 by Nutster, on Sep 17, 2009 at 3:18:03 AM

Owner: set to Nutster
Status: reopenedaccepted

comment:9 by TicketCleanup, on Sep 17, 2009 at 4:00:01 AM

Milestone: Future Release

Automatic ticket cleanup.

comment:10 by Valik, on Oct 17, 2009 at 12:53:06 AM

Severity: NoneBlocking

comment:11 by Nutster, on Oct 19, 2009 at 4:40:14 AM

Milestone: 3.3.1.4
Resolution: Completed
Status: acceptedclosed

Added in version: 3.3.1.4

Modify Ticket

Action
as closed The owner will remain Nutster.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.