The EVALUATE statement describes a multi-branch, multi-join
structure. It can cause multiple conditions to be evaluated. The subsequent
action of the runtime element depends on the results of these evaluations.
General Format

Syntax Rules
- The operands or the words TRUE and FALSE which appear before the
first WHEN phrase of the EVALUATE statement are referred to individually as
selection subjects and collectively, for all those specified, as the set of
selection subjects.
- The operands or the words TRUE, FALSE, and ANY which appear in a
WHEN phrase of an EVALUATE statement are referred to individually as selection
objects and collectively, for all those specified in a single WHEN phrase, as
the set of selection objects.

The classification of some selection
subjects or selection objects is changed for a particular WHEN phrase as
follows:
- If the selection subject is TRUE or FALSE and the selection
object is a boolean expression that results in one boolean character, the
selection object is treated as a boolean condition.
- If the selection object is TRUE or FALSE and the selection
subject is a boolean expression that results in one boolean character, the
selection subject is a treated as boolean condition.
- If the selection subject is other than TRUE or FALSE and the
selection object is a boolean expression that results in one boolean character,
the selection object is treated as a boolean expression.
- If the selection object is other than TRUE or FALSE and the
selection subject is a boolean expression that results in one boolean
character, the selection subject is treated as a boolean expression.
- If the selection object is a partial expression and the
selection subject is a data item of the class boolean or numeric, the selection
subject is treated as an identifier.
- The words THROUGH and THRU are equivalent.
- Two operands connected by a THROUGH phrase must be of the same
class (but not boolean). The two operands thus connected constitute a single
selection object.
- The number of selection objects in each set of selection objects
must be equal to the number of selection subjects.
- Each selection object in a set of selection objects must
correspond to the selection subject having the same ordinal position in the set
of selection subjects according to the following rules:
- Identifiers, literals, or arithmetic expressions appearing in
a selection object must be valid operands for comparison to the corresponding
operand in the set of selection subjects. (See the topic
Relation
Condition in the chapter Procedure
Division.)
- Condition-1, condition-2, or the words TRUE or FALSE
appearing as a selection object must correspond to a conditional expression or
the words TRUE or FALSE in the set of selection subjects.
- The word ANY can correspond to a selection subject of any
type.

Where identifiers are
permitted, they can reference floating-point data items.

Where numeric literals are
permitted, floating-point literals are permitted.

Where identifiers are
permitted, they can reference pointer data items.
- A selection object is a partial-expression if the leftmost
portion of the selection object is a relational operator, a class condition
without the identifier, a sign condition without the identifier, or a sign
condition without the arithmetic expression.

If partial-expression-1 or
partial-expression-2 is specified as a selection object, it must correspond to
a selection subject that is an identifier, a literal or an arithmetic
expression. Partial-expression-1 and partial-expression-2 must be a sequence of
COBOL words which, when following the corresponding selection subject, make the
resultant text a valid conditional expression.
General Rules
- The execution of the EVALUATE statement operates as if each
selection subject and selection object were evaluated and assigned a numeric or
nonnumeric value, a range of numeric or nonnumeric values, or a truth value.
These values are determined as follows:
- Any selection subject specified by identifier-1,
identifier-2, and any selection object specified by identifier-3, identifier-5,
without either the NOT or the THROUGH phrases, are assigned the value and class
of the data item referenced by the identifier.

If the selection
subject is a numeric data item or a boolean data item whose length is one
boolean position, the selection subject for this evaluation is treated as
identifier-1 and not an arithmetic or boolean expression.
- Any selection subject specified by literal-1, literal-2, and
any selection object specified by literal-3, literal-5, without either the NOT
or the THROUGH phrases, are assigned the value and class of the specified
literal. If literal-3, literal-5, is the figurative constant ZERO, it is
assigned the class of the corresponding selection subject.
- Any selection subject in which expression-1, expression-2, is
specified as an arithmetic expression and any selection object, without either
the NOT or the THROUGH phrases, in which arithmetic-expression-1,
arithmetic-expression-3, is specified are assigned a numeric value according to
the rules for evaluating an arithmetic expression. (See the topic
Arithmetic
Expressions in the chapter Procedure
Division.)
- Any selection subject in which expression-1, expression-2 is
specified as a conditional expression and any selection object in which
condition-1, condition-2, is specified are assigned a truth value according to
the rules for evaluating conditional expressions. (See the topic
Conditional
Expressions in the chapter Procedure
Division.)
- Any selection subject in which boolean-expression-1 is
specified is assigned a boolean value according to the rules for evaluating
boolean expressions.
- Any selection subject or any selection object specified by
the words TRUE or FALSE is assigned a truth value. The truth value "true" is
assigned to those items specified with the word TRUE, and the truth value
"false" is assigned to those items specified with the word FALSE.
- Any selection object specified by the word ANY is not further
evaluated.
- If the THROUGH phrase is specified for a selection object,
without the NOT phrase, the range of values is all values which, when compared
to the selection subject, are greater than or equal to the first operand and
less than or equal to the second operand according to the rules for comparison.
(See the topic
Relation
Condition in the chapter Procedure
Division.
- If the NOT phrase is specified for a selection object, the
values assigned to that item are all values not equal to the value, or range of
values, which would have been assigned to the item had the NOT phrase not been
specified.
- The execution of the EVALUATE statement then proceeds as if the
values assigned to the selection subjects and selection objects were compared
to determine if any WHEN phrase satisfies the set of selection subjects. This
comparison proceeds as follows:
- Each selection object in the set of selection objects for the
first WHEN phrase is compared to the selection subject having the same ordinal
position in the set of selection subjects.
- If the items being compared are assigned numeric or
nonnumeric values, or a range of numeric or nonnumeric values, the comparison
is satisfied if the value, or one of the range of values, assigned to the
selection object is equal to the value assigned to the selection subject
according to the rules for comparison. (See the topic
Relation
Condition in the chapter Procedure
Division.)
- If the items being compared are assigned truth values,
the comparison is satisfied if the items are assigned the identical truth
value.
- If the selection object being compared is specified by
the word ANY, the comparison is always satisfied regardless of the value of the
selection subject.
- If the above comparison is satisfied for every selection
object in the set of selection objects being compared, the WHEN phrase
containing that set of selection objects is selected as the one satisfying the
set of selection subjects.
- If the above comparison is not satisfied for one or more
selection objects in the set of selection objects being compared, that set of
selection objects does not satisfy the set of selection subjects.
- This procedure is repeated for subsequent sets of selection
objects, in the order of their appearance in the source element, until either a
WHEN phrase satisfying the set of selection subjects is selected or until all
sets of selection objects are exhausted.
- After the comparison operation is completed, execution of the
EVALUATE statement proceeds as follows:
- If a WHEN phrase is selected, execution continues with the
first imperative-statement-1 following the selected WHEN phrase.
- If no WHEN phrase is selected and a WHEN OTHER phrase is
specified, execution continues with imperative-statement-2.
- The scope of execution of the EVALUATE statement is
terminated when execution reaches the end of the scope of the selected WHEN
phrase or WHEN OTHER phrase or when no WHEN phrase is selected and no WHEN
OTHER phrase is specified. (See the topic
Explicit and Implicit
Scope Terminators in the chapter Concepts of the
COBOL Language.)

If the selection object is
specified by partial-expression-1 or partial-expression-2, the corresponding
selection subject is considered to be the word TRUE. The selection object is
considered to be condition-1 or condition-2 respectively, where condition-1 or
condition-2 is the conditional expression resulting from partial expression-1
or partial-expression-2 following the original corresponding
selection-subject-1 or selection-subject-2 respectively.