LOCAL
Declares memory variables that are visible only in the routine where they're declared.
Syntax
LOCAL <memvar list>
<memvar list>
The list of memory variables to declare local.
Description
Use LOCAL to declare a list of memory variables available only to the routine in which the command is issued. Local variables differ from those declared PRIVATE in the following ways:
Private variables are available to lower-level subroutines, while local variables are not. Local variables are accessible only to the routine—the program or function—in which they are declared.
TYPE( ) does not "see" local variables. If you want to determine the TYPE( ) of a local variable, you must copy it to a private (or public) variable and call TYPE( ) with that variable name in a string.
You cannot use a local variable for macro substitution with the & operator. Again, you must copy it to a private (or public) variable first.
LOCAL variables cannot be inspected using the Debugger.
Despite these limitations, local variables are generally preferred over private variables because of their limited visibilty. You cannot accidentally overwrite them in a lower-level routine, which would happen if you forget to hide a public variable; nor can you inadvertently use a variable created in a higher-level routine, thinking that it’s one declared in the current routine, which would happen if you misspell the variable name in the current routine.
Note The special variables this and form are local.
You must declare a variable LOCAL before initializing it to a particular value. Declaring a variable LOCAL doesn't create it, but it does hide any higher-level variable with the same name. After declaring a variable LOCAL, you can create and initialize it to a value with STORE or =. (The := operator will not work at this point because the variable hasn’t been created yet.) Local variables are erased from memory when the routine that creates them finishes executing.
For more information, see PUBLIC for a table that compares the scope of public, private, local, and static variables.