| Directives |
|
| Format | 1.
Assign
Local Variables: LOCAL varlist 2. Define Local Properties (OOP): LOCAL prop1[OBJECT], prop2 [OBJECT].... 3. Define Local variables in Functions: DEF FNxxxxx ( LOCAL var [ , LOCAL var ...] )
|
|||||||||
| Description | The LOCAL directive is used to reassign variable names temporarily, without affecting the original contents. In Object Oriented Programming (OOP), the LOCAL directive is similar to the PROPERTY directive, but is used to declare data that is only visible to processing logic. | |||||||||
| Format 1 | Assign Local Variables
Use this format to reassign variable names temporarily, without affecting the original contents. If the variable name supplied in the LOCAL directive is in current use, ProvideX will preserve its value/contents. Once the current FOR/GOSUB stack has been cleared or the program is exited, ProvideX restores variables that were designated local to their original values. (Local variables are only active until the current stack is cleared.) The LOCAL directive can take an assignment during declaration; however, direct assignment does not work for arrays that are declared as local. In the example below, X is designated as local for both subroutines (CHK_IT and LOOP), so the value of X is restored to its original value "1234" after the GOSUB stack is cleared for each subroutine. Since X$ was not designated as LOCAL in the LOOP subroutine, its value has changed from "START TEST, X=" to "LOOP" after the GOSUB stack for the LOOP has been cleared.
Variables in function definitions can be designated as local to prevent changes in program variables:
|
|||||||||
| Format 2 | Define Local Properties
in Object Oriented Programming
In Object Oriented Programming, the LOCAL directive can be used to define the properties for an object class that are not exposed to external applications. They can be accessed during the execution of program logic within the object class itself. This format of the LOCAL directive is similar to the PROPERTY directive: variable declarations may include dimensioned arrays and object references. LOCAL properties are typically used for:
If the local variable contains an object identifier to another object, specify the keyword OBJECT after the variable name. When the object is deleted, ProvideX will use the REF( ) function against the object identifier to remove it (as long as it has no other references); e.g.,
When you delete an object whose class is Customer, then the system reduces the reference count of the object whose identifier is in File and, if it is no longer being referenced, deletes it as well. Refer to the following functions and directives for related information on Object Oriented Programming: DEF CLASS Define Object Class
|
|||||||||
| Format 3 | Define Local variables
for user defined functions
When defining a user function, the LOCAL keyword can be used to specify that the variables declared in the paramerer list are local to the function. That is the assignment of values from the function invocation parameter list will only effect the variables while within the function. |
|||||||||