&IF, &THEN, &ELSEIF, &ELSE, and &ENDIF preprocessor directives
These directives set logical conditions for the inclusion of blocks of code to compile.
Syntax
expression
When it encounters an &IF directive, the preprocessor evaluates the expression that immediately follows. This expression can continue for more than one line; the &THEN directive indicates the end of the expression. If the expression evaluates to TRUE, then the block of code between it and the next &ELSEIF, &ELSE, or &ENDIF is compiled. If the expression evaluates to FALSE, the block of code is not compiled and the preprocessor proceeds to the next &ELSEIF, &ELSE, or &ENDIF directive. No include files referenced in this block of code are included in the final source. You can nest &IF directives.
The expression that follows the &ELSEIF directive is evaluated only if the &IF expression tests false. If the &ELSEIF expression tests TRUE, the block of code between it and the next &ELSEIF, &ELSE, or &ENDIF directive is compiled. If the &ELSEIF expression tests FALSE, the preprocessor proceeds to the next &ELSEIF, &ELSE, or &ENDIF directive.
The block of code between the &ELSE and &ENDIF directives is compiled only if the &IF expression and the &ELSEIF expressions all test false. If there are no &ELSEIF directives, the block of code is compiled if the &IF expression tests false.
Once any &IF or &ELSEIF expression evaluates to TRUE, no other block of code within the &IF...&ENDIF block is compiled.
The &ENDIF directive indicates the end of the conditional tests and the end of the final block of code to compile.
Table 5 shows how preprocessor expressions are evaluated.
Table 5: Preprocessor expressions Type of expression TRUE FALSE LOGICAL TRUE FALSE CHARACTER non-empty empty INTEGER non-zero 0 INT64 non-zero 0 DECIMAL not supported not supported
Table 6 lists the operators supported within preprocessor expressions. These operators have the same precedence as the regular ABL operators.
Table 7 lists the ABL functions supported within preprocessor expressions.
NoteWhen the preprocessor evaluates expressions, all arithmetic operations are performed with integers. Preprocessor name references used in arithmetic operations must evaluate to integers.
See also&GLOBAL-DEFINE preprocessor directive, &SCOPED-DEFINE preprocessor directive, &UNDEFINE preprocessor directive
OpenEdge Release 10.2B
|