Note | This command is not available in the Core and Vulcan dialects |
Purpose
Declare one or more memory variable names to be used by the current routine.
MEMVAR <idMemvarList>
<idMemvarList> | A list of public and private variable names to declare to the compiler. |
When you use the MEMVAR statement to declare variables, unaliased references to variables in <idMemvarList> are treated as if they were preceded by the special memory variable alias
(_MEMVAR->).
Like other variable declaration statements (such as LOCAL and FIELD), you must place MEMVAR statements before any executable statements (including PRIVATE, PUBLIC, and PARAMETERS) in the routine you are defining. The MEMVAR statement has no effect on the macro operator, which always assumes memory variables.
The MEMVAR statement neither creates the variables nor verifies their existence. Its primary purpose is to ensure correct references to variables that are known to exist at runtime. Attempting to access variables before they are created will raise a runtime error.
This example demonstrates the relationship between a private and field variable with the same name. The private variable is declared with the MEMVAR statement:
FUNCTION Example()
MEMVAR Amount, Address
PRIVATE Amount := 100
USE customer NEW
? Amount // Refers to Amount private variable
? Customer->Amount // Refers to Amount field variable
FIELD, LOCAL, PARAMETERS, PRIVATE, PUBLIC, STATIC