| Directives |
|
| Format | STATIC
[ varlist | * ] Where:
|
|||
| Description | In
Object Oriented Programming
(OOP), the STATIC directive is used to
create variables for use within an object at runtime that
will be preserved within the object instance. Basically, STATIC
is used to extend the list of LOCAL properties
at runtime. This allows for the dynamic creation of
variables which are visible to operations within an
object, yet which are not directly accessible to outside
code. Specifing an asterisk indicates all variables are to be considered LOCAL and is refered to as 'Full Variable Persistence' (see below) For Example:
All the named variables will be LOCAL so that their values will remain current while executing logic within the object. Using the STATIC clause, an object that is accessing a data file with an embedded IOList will be able to handle extensions to the IOList going forward. This allows the object to then read a record from the file and have the data elements remain available for subsequent calls to the object's methods. Duplicate variables are ignored; i.e., if a variable has already been declared STATIC, is a PROPERTY, or has been declared LOCAL for an object, then no error is reported. Static variables will include their associated arrays; therefore, STATIC A$ also means that A$[1],... are all static. |
|||
| *Note* | Ensure that the STATIC declaration occurs before the variables are used - static variables will only take effect on references that follow their declaration. | |||
| Full Variable Persistence | The
STATIC * directive indicates that all
variables used within an object are to be preserved
within the Object. This means that any variable value set
during the execution of the object will remain set on
subsequent method/function calls. The directive can be placed within either within the class definition or executed at any time during the execution of the object. Once 'Full Variable Persistence' is enabled within an object, it cannot be disabled. |
|||
| *Note* | Full variable persistence is not honoured for functions/methods within an object that are declared as 'Performed'. This is due to the fact that performed functions share the variable space with the calling logic. | |||
| See Also | Object
Oriented Programming DEF CLASS Define Object Class DROP CLASS Delete Class Definition DROP OBJECT Delete Object FUNCTION Declare Object Method LIKE Inherit Properties LOAD CLASS Pre-Load Class Definition LOCAL Designation of Local Data PROGRAM Create/Assign Program File PROPERTY Declare Object Properties RENAME CLASS Change Name of Class NEW( ) Function REF( ) Function |
|||