Previous Next

&IF, &THEN, &ELSEIF, &ELSE, and &ENDIF preprocessor directives
These directives set logical conditions for the inclusion of blocks of code to compile.
Syntax 
 
&IF expression &THEN
  block
[ &ELSEIF expression &THEN
  block ] ...
[ &ELSE
  block ]
&ENDIF
expression
An expression that can contain preprocessor name references, the operators listed in Table 6, the ABL functions listed in Table 7, and the DEFINED( ) preprocessor function.
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 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.
Note 
When 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
 

Previous Next
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates.