Language basics / Variables |
A variable contains volatile information of a specific data type.
[PUBLIC|PRIVATE] DEFINE variable-definition [,...]
where variable-definition is:
identifier [,...] { datatype | LIKE [dbname:]tabname.colname }
A variable is a named location in memory that can store a single value, or an ordered set of values. Variables can be global to the program, module-specific, or local to a function.
You cannot reference any program variable before it has been declared by the DEFINE statement.
By default, module-specific variables are private; They cannot be used by an other module of the program. In order to improve code re-usability by data encapsulation, we recommend you to keep module variables private, except if you want to share large data (like arrays) between modules. To make a module variable public, add the PUBLIC keyword before DEFINE. When a module variable is declared as public, it can be referenced by another module by using the IMPORT instruction.
When defining variables with the LIKE clause, the data types are taken from the database schema file at compile time. Make sure that the schema file of the database schema during development corresponds to the database schema of the production database; otherwise the variables defined in the compiled version of your modules will not match the table structures of the production database.
To write well-structured programs, avoid global variables. If you need persistent data storage during a program's execution, use variables local to the module and give access to them with functions, or make the module variables PUBLIC to other modules.