The EVALUATE directive provides a way of evaluating which source lines to include in a compilation group.
Note: In this section, the compiler directing statements DEFINE, EVALUATE, and IF are referenced using the ISO2002 terminology of
directives. When referring to the DEFINE Compiler option, it will be explicitly referenced as such.
General Format 1
General Format 2
General Format 3
Syntax Rules for All Formats
- Throughout the rules descriptions:
- operand-1 refers to literal-1 or arithmetic-expression-1 in format 1, and to the TRUE or FALSE keyword in formats 2 and 3.
- operand-2 refers to literal-2 or arithmetic-expression-2 in format 1, and to constant-conditional-expression-1 in formats
2 and 3.
- operand-3 refers to literal-3 or arithmetic-expression-3 in format 1.
- The keywords >>EVALUATE. >>WHEN, >>WHEN OTHER, and >>END-EVALUATE must begin on a new line in either area A or area B, and
must be specified entirely on that line.
- The identifiers text-1 and text-2:
- Must begin on a new line, and can consist of multiple lines.
- May be any kind of source lines, including compiler directives.
- May also include COPY statements.
- The phrases of a given EVALUATE directive must be specified all in the same library text or all in source text. For purposes
of this rule, text-1 and text-2 are not considered phrases of the EVALUATE directive.
- A nested EVALUATE directive specified in text-1 or text-2 is considered a new EVALUATE directive.
Syntax Rules for Format 1
- All operands of the EVALUATE directive must be of the same category. (Arithmetic expressions are considered of category numeric.)
- The phrases THROUGH and THRU are equivalent.
- If the THROUGH or THRU phrase is specified, all selected items must be of category numeric.
- arithmetic-expression-1, arithmetic-expression-2, and arithmetic-expression-3 must be constructed as per the rules as stated
in
Appendix E - Compile-Time Arithmetic Expressions.
Syntax Rules for Format 2 and Format 3
- constant-conditional-expression-1 must be constructed as per the rules as stated in
Appendix B - Constant Conditional Expressions.
General Rules for All Formats
- text-1 and text-2 do not form part of the EVALUATE directive line.
- text-1 and text-2 that are in the first true branch of the EVALUATE statement are subject to matching and replacing rules,
as per COPY and REPLACE statements.
- If the statement reaches the END-EVALUATE keyword without any WHEN phrase evaluating true (or false for EVALUATE FALSE constructs),
or without encountering a WHEN OTHER phrase, all lines of text-1 associated with WHEN phrases are omitted from the result.
General Rules for Format 1
- The comparison of the selection subject to the values specified in each WHEN phrase is as follows:
- If the THROUGH phrase is not specified, a TRUE result is returned if the selection subject is equal to operand-2.
- When the THROUGH phrase is specified, a TRUE result is returned if the selection subject is greater than or equal to operand-2,
and less than or equal to operand-3.
- If a WHEN phrase evaluates TRUE, the lines of text-1 associated with that WHEN phrase are included in the resultant text.
All other text-1 and text-2 lines in the EVALUATE directive are omitted.
- If no WHEN phrase evaluates TRUE, all lines of text-2 associated with the WHEN OTHER phrase, if specified, are included in
the resultant text. All text-1 lines in the EVALUATE directive are omitted.
- If literal-1 is alphanumeric, a character-by-character comparison for equality, based on the binary representation of each
character's encoding, is used. They are not equal if the literals are of unequal length.
General Rules for Format 2
- For each WHEN phrase in turn, constant-conditional-expression-1 is evaluated according to the rules as stated in
Appendix B - Constant Conditional Expressions.
- If a WHEN phrase evaluates to TRUE, the lines of text-1 associated with that WHEN phrase are included in the resultant text.
All other text-1 and text-2 lines in the EVALUATE directive are omitted.
- If no WHEN phrase evaluates TRUE, all lines of text-2 associated with the WHEN OTHER phrase, if specified, are included in
the resultant text. All text-1 lines in the EVALUATE directive are omitted.
General Rules for Format 3
- For each WHEN phrase in turn, constant-conditional-expression-1 is evaluated according to the rules as stated in
Appendix B - Constant Conditional Expressions.
- If a WHEN phrase evaluates to FALSE, the lines of text-1 associated with that WHEN phrase are included in the resultant text.
All other text-1 and text-2 lines in the EVALUATE directive are omitted.
- If no WHEN phrase evaluates FALSE, all lines of text-2 associated with the WHEN OTHER phrase, if specified, are included in
the resultant text. All text-1 lines in the EVALUATE directive are omitted.