Opened 16 years ago

Closed 14 years ago

#508 closed Feature Request (Completed)

Static variables

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


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.

Bruce Huber

Attachments (0)

Change History (11)

comment:1 Changed 16 years ago by Gary

look at "Global Const"

comment:2 Changed 16 years ago by Valik

  • Resolution set to Rejected
  • Status changed from new to closed

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 Changed 16 years ago by Valik

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

comment:4 Changed 16 years ago by TicketCleanup

  • Version deleted

Automatic ticket cleanup.

comment:5 follow-up: Changed 16 years ago by Gary

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.

comment:6 in reply to: ↑ 5 Changed 16 years ago by cbruce

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,

comment:7 Changed 14 years ago by Nutster

  • Milestone set to Future Release
  • Resolution Rejected deleted
  • Status changed from closed to reopened

I'll start working on this.

comment:8 Changed 14 years ago by Nutster

  • Owner set to Nutster
  • Status changed from reopened to accepted

comment:9 Changed 14 years ago by TicketCleanup

  • Milestone Future Release deleted

Automatic ticket cleanup.

comment:10 Changed 14 years ago by Valik

  • Severity changed from None to Blocking

comment:11 Changed 14 years ago by Nutster

  • Milestone set to
  • Resolution set to Completed
  • Status changed from accepted to closed

Added in version:

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The owner will remain Nutster.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.