The EVALUATE directive supports the conditional compilation of multiple alternatives.
Format 1
>>EVALUATE {arithmetical-expression-1 | boolean-expression-1}
{>>WHEN {arithmetical-expression-2 | boolean-expression-2}
[{THROUGH | THRU} arithmetical-expression-3]
[source-text-1]}...
[>>WHEN OTHER
[source-text-2]]
>>END EVALUATE
Format 2
>>EVALUATE TRUE
{>>WHEN boolean-expression-1
[source-text-1]}...
[>>WHEN OTHER
[source-text-2]]
>>END-EVALUATE
Syntax rules
All formats:
THRU is the abbreviated form of THROUGH.
The parts of the compiler directive introduced with >> must be specified together with the succeeding operands, each in a separate line.
source-text-1 and source-text-2 must begin on a new line.source-text-1 and source-text-2 may contain any source code lines, including compil-text-1 and source-text-2 may each span multiple lines.
source-text-1 and source-text-2 may contain a maximum of 1 COPY statement in any line.
Format 1
All operands of one EVALUATE directive must be of the same category. For this rule, an arithmetic expression is of category “numeric” and a boolean expression is of category “boolean”.
If the THROUGH phrase is specified, all selection items must be of category “numeric”.
General rules
All formats
The EVALUATE directive is processed during the execution of the COPY and REPLACE statements.
As soon as a WHEN phrase evaluates to TRUE, the associated source-text-1 is compiles, including >>END-EVALUATE, are ignored. If none of the WHEN phrases evaluate to TRUE, then source-text-2, if specified, is compiled, and all other lines are ignored.
Format 1
arithmetic-expression-1 and boolean-expression-1 are compared with the values in the WHEN phrase in accordance with the following rules:
If THROUGH is not specified, the value ‘true’ is returned when arithmetic expression-1 or boolean-expression-1 is equal to arithmetic-expression-2 or boolean-expression-2,
If THROUGH is specified, the value ‘true’ is returned when arithmetic-expression-1 lies in the value range of arithmetic-expression-2 and arithmetic-expression-3.