&GLOBAL-DEFINE preprocessor directive

Globally defines a compile-time constant (preprocessor name).

Syntax

&GLOBAL-DEFINE preprocessor-name definition
preprocessor-name
The preprocessor name (compile-time constant) that you supply. ABL reserved keywords are allowed, but cannot be used in preprocessor expressions.
definition
A string of characters (or preprocessor references that evaluate to a string of characters) whose content the preprocessor substitutes for preprocessor-name during compilation. If the definition is longer than one line, a tilde (~) at the end of a line indicates continuation to the next line.

Examples

In this example, the preprocessor name MAX-EXPENSE is defined as the text string "5000":

&GLOBAL-DEFINE MAX-EXPENSE 5000

Wherever the reference {&MAX-EXPENSE} appears in the source code, the preprocessor substitutes the text string "5000". For example, the preprocessor changes this line of code:

IF tot-amount <= {&MAX-EXPENSE} THEN DO:

To this line:

IF tot-amount <= 5000 THEN DO:

Notes

  • You must place the &GLOBAL-DEFINE directive at the beginning of a line, preceded only by blanks, tab characters, or multi-line comments (/* comment */).
  • The preprocessor trims all leading and trailing spaces from definition.
  • The syntax of the &GLOBAL-DEFINE and &SCOPED-DEFINE directives are identical but these directives are used differently.
  • If duplicate &GLOBAL-DEFINE directives are specified for the same preprocessor-name, the last &GLOBAL-DEFINE directive is applied.
  • The compiler removes /* Multi-line comments */ on lines of ABL code with preprocessor directives. To retain comments, use // Single-line comments or escape the multi-line comment using a tilde (~). For example, &SCOPED-DEFINE VAR3 DEF VAR xpos AS INT. /~* column position of fill-in *~/.

See also

{ } Preprocessor name reference, &SCOPED-DEFINE preprocessor directive, &UNDEFINE preprocessor directive, DEFINED preprocessor function