COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-70
EVALUATE
THROUGH
THRU
indicate that a range of values is to be compared. Two operands
combined by THROUGH or THRU must be of the same class
(alphabetic, alphanumeric, or numeric). The two operands thus
connected constitute a single selection object.
match-imp-stmt
is an imperative statement to be executed when the values of the objects in the
associated object-list match the values of the corresponding subjects in the
subject-list.
no-match-imp-stmt
is an imperative statement to be executed when no match-imp-stmt applies.
After no-match-imp-stmt executes, control passes to the end of the
EVALUATE statement.
END-EVALUATE
ends the scope of the EVALUATE statement and makes it a delimited-scope
statement. If you omit END-EVALUATE, the EVALUATE statement is a conditional
statement and ends at the next period separator.
Usage Considerations:
EVALUATE in Comparison to “Case” Statement
The EVALUATE statement is a generalization of what some languages call the
“case” statement, a statement that enables you to execute one of several groups of
statements depending on the value of a single data item.
Example 9-19. EVALUATE Statement as “Case” Statement
EVALUATE TRAN-CODE
WHEN 1 PERFORM TRAN-1
WHEN 2 PERFORM TRAN-2
WHEN 3 PERFORM TRAN-3
WHEN OTHER PERFORM TRAN-BAD
END-EVALUATE
Example 9-20. EVALUATE Statement With Both Ranges and Discrete Values
EVALUATE SALARY OF PAYROLL-REC
WHEN 15000 THRU 29999.99 PERFORM LOW-BRACKET
WHEN 30000 THRU 49999.99 PERFORM MIDL-BRACKET
WHEN 50000 THRU 99999999 PERFORM HIGH-BRACKET
WHEN OTHER PERFORM NO-BRACKET
END-EVALUATE