Language Reference Guide : 7. Preprocessing Your 4GL Code : Preprocessor : User-defined Macro Variables
 
Share this page                  
User-defined Macro Variables
You can define and edit your own macro variables in the Macro Variable Editor. The macro variables you define become part of the frame definition or procedure.
User-defined macro variable names are not case-sensitive and can have a total length of up to 32 characters.
Macro variable names must begin with a "$", followed by an alpha character. The remaining characters may be alpha, numeric, or underscore characters. We recommend that user-defined macro variables not begin with "$_" because OpenROAD's built-in macro variables begin this way. The "$" is considered part of the length. For example:
Invalid: $7DigitsMask is not a valid macro variable name because the first character following the "$" is not alpha.
Invalid: $A_Really_Long_Macro_Variable_Name is not valid because it exceeds 32 characters.
Not recommended: $_10DigitsMask is not recommended because the first character following the "$" is an underscore.
Recommended: $TenDigitsMask
The value of macro variables cannot evaluate to a preprocessor statement or the name of another macro variable. Macro variables' duration begins when they are defined, and they exist throughout the remainder of a source file.
If you define a macro variable in one field script and then use the macro variable in another field script, processing errors may occur because of the order in which the field scripts are processed. To avoid this error when using a macro variable throughout a frame, declare the macro variable in the frame script or create it interactively.
You can also define macro variables in a script for frames, procedures, or user classes with the #define statement. After a macro variable is defined, it is defined for the rest of the script until it is undefined (with the #undef statement).
For frames that may have separate scripts in many components (fields, menu items), be careful about defining a macro variable in one script and using it in another. The only thing you assume about script ordering is that composite scripts appear before the scripts of the composite's child fields.
You use the #define statement to create your macro variables as detailed in The #define Statement.
For more information about using the Macro Variable Editor, see the Workbench User Guide.