|
Static | |||
Static <.varname.> | |||
Parameters: NONE | |||
Returns: NONE | |||
Static variables are a special form of local variable within Functions. Just like the Local directive, Static declarations affect the visibility of variables. However, local variables (those inside functions) will be initialised every time the Function is called, a static variable, will keep its current value/string between calls. Static supports three basic forms, You can simply define a single static, a list of statics using comas to separate them, or define a static with an assignment. i.e.
Note: Variables defined as Static will have precedence over any variable of the same name, that's defined in main program as global. FACTS: * Static variables can only be defined within a Function block * Static can handle assignments. I.e. (Static Score=1000) * Static can handle lists by using coma's between them. I.e. (Static Monday,Tuesay,Wednesday,Thursday,Friday) * Static Variables have precedence over any variable of the same name that was defined in main program as global. Mini Tutorial : This simple examples is meant to show the difference between Local and Static variables
The output of this example would be:
|
Related Info: | Constant | Dim | Explicit | Function | Functions&Psub | Global | Local | Psub | Variables : |
|
|||||||||||||||||||||||||||||||||||||||
(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com |