Statement PRIVATE Foundation
PRIVATE-Creates and initializes memory variables of the storage class PRIVATE.
PRIVATE <VarName> [[:= <Expression>], ... ]
The PRIVATE statement creates memory variables of the storage class PRIVATE. Storage classes define the lifetime and the visibility of variables. With the PRIVATE statement, so-called "dynamic" memory variables are created at runtime and whose references the compiler does not resolve. The PRIVATE statement belongs to the executable statements and must always follow variable declarations such as MEMVAR, FIELD, LOCAL or STATIC.
The declaration of a PRIVATE variable takes place with the declaration MEMVAR. The generation of such a variable explicitly takes place with the PRIVATE statement or implicitly with assignment of a value to an undeclared variable. PRIVATE variables can also be created from character string expressions using the macro operator (&) at runtime. Since the symbolic variable name of PRIVATE variables exists at runtime, they can be saved in files and restored at runtime. This is not possible with LOCAL or STATIC variables.
<VarName> may occur only once within a function. This includes variables which are declared as STATIC or LOCAL. If a PRIVATE or PUBLIC variable of the name <VarName> already exists in a calling function, the existing variable is hidden and is no longer visible within the function or procedure in which the new PRIVATE variable of the same name was declared.
The length of a variable name is unlimited, but only the first 255 characters are significant. A variable consists of alphanumeric characters, and the first character may not be numeric. The underscore (_) is permitted as a special character.
The lifetime of a PRIVATE variable extends implicitly to the lifetime of the function or procedure in which the variable was created. It is released after the function terminates, but can also be deleted with one of the commands CLEAR ALL, CLEAR MEMORY or RELEASE. A private variable remains visible in called functions and procedures until, if necessary, a new variable is created with the same name as the variable in the calling function or procedure.
A PRIVATE variable can be initialized when it is declared, meaning the value of any expression can be assigned to it with help of the inline assignment operator (:=), or it can be initialized by use of the array element operator [] with any dimension and size. If no assignment is done, PRIVATE variables have the value NIL after generation. When they are initialized as an array, no further assignment is possible and all the array elements have the value NIL.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.