EVALUATE Directive
The EVALUATE directive provides for multi-branch conditional
compilation.
General Format


Syntax Rules
- Each pair of contiguous COBOL characters >> and the
succeeding compiler-directive words and operands up to, but not including,
source-text-1 and source-text-2 must be specified on a new line and be
specified entirely on that line. The first text-word of source-text-1 and the
first text-word of source-text-2 must each begin on a new line.
- Source-text-1 and source-text-2 can be any kind of source text,
including compiler directives. Source-text-1 and source-text-2 can span
multiple lines.
- All operands of one EVALUATE directive must be of the same
category. For this rule, an arithmetic expression is of category numeric.
- If the THROUGH phrase is specified, all selection subjects and
selection objects must be of category numeric.
- The words THROUGH and THRU are equivalent.
General Rules
- The EVALUATE directive is processed during the processing of COPY
and REPLACE statements.
- Literal-1 or arithmetic-expression-1, referred to as the
selection subject, is compared against the values specified in each WHEN phrase
in turn as follows:
- If the THROUGH phrase is not specified, a TRUE result is
returned if the selection subject is equal to literal-2 or
arithmetic-expression-2.
- If the THROUGH phrase is specified, a TRUE result is returned
if the selection subject lies in the inclusive range determined by literal-2 or
arithmetic-expression-2 and literal-3 or arithmetic-expression-3.
As soon as a WHEN phrase is found that yields a TRUE result, the
associated source-text-1 is compiled and all remaining lines up to and
including the >>END-EVALUATE line are ignored. If no WHEN phrase yields a
TRUE result, the source-text-2 associated with the >>WHEN OTHER phrase,
if specified, is compiled.
- For each WHEN phrase in turn, the constant-conditional-expression
is evaluated.
As soon as a WHEN phrase is found that yields a TRUE result, the
associated source-text-1 is compiled and all remaining lines up to and
including the >>END-EVALUATE line are ignored. If no WHEN phrase yields a
TRUE result, the source-text-2 associated with the >>WHEN OTHER, if
specified, is compiled.