COBOL Manual for TNS/E Programs (H06.03+)
Procedure Division Verbs
HP COBOL Manual for TNS/E Programs—520347-003
9-64
EVALUATE
The WHEN OTHER phrase is commonly used as the mechanism for handling errors,
enabling the program to detect invalid values for subjects and improper specification of
objects.
•
Subject-Object Correspondence
Every object-list must have an object for every subject in the
subject-list. Each object in an object-list must correspond to the
subject that has the same ordinal position in the subject-list. The rules that
determine whether a subject and object correspond are:
°
The object value ANY corresponds to any subject value.
°
An object that is a condition or the value TRUE or FALSE corresponds to a
subject that is a conditional expression or the value TRUE or FALSE.
°
An object composed of identifiers, literals, or arithmetic expressions
corresponds to a subject if the value of the object is a valid operand for
comparison to the subject.
•
Subject-Object Comparisons
EVALUATE operates as if each corresponding subject and object were
evaluated and assigned one of:
°
A numeric or nonnumeric value
°
A range of numeric or nonnumeric values
°
TRUE
°
FALSE
The subject is determined:
Example 9-20. EVALUATE Statement as a Decision Table
EVALUATE XXX ALSO "GONE" ALSO ( A + B ) / C ALSO X = Y
WHEN 5 ALSO ANY ALSO 25 ALSO TRUE
PERFORM PROC-A
WHEN 10 THRU 30 ALSO YYY ALSO 2 ALSO FALSE
PERFORM PROC-B
WHEN OTHER ADD 1 TO VACUOUS-COUNT
END-EVALUATE
subject EVALUATE uses …
identifier The value and class of the data item referenced by identifier
literal The value and class of literal
arithmetic expression The numeric value determined by the rules for evaluating
arithmetic expressions
conditional expression The truth value determined by the rules for evaluating
conditional expressions
TRUE TRUE
FALSE FALSE










