Example: EVALUATE using multiple WHEN phrases
The following example shows that you can code multiple WHEN
phrases
if several conditions should lead to the same action. Doing so gives
you more flexibility than using only the THRU
phrase,
because the conditions do not have to evaluate to values in a range
nor have the same class.
EVALUATE MARITAL-CODE
WHEN "M"
ADD 2 TO PEOPLE-COUNT
WHEN "S"
WHEN "D"
WHEN "W"
ADD 1 TO PEOPLE-COUNT
END-EVALUATE
The following nested IF
statements
represent the same logic:
IF MARITAL-CODE = "M" THEN
ADD 2 TO PEOPLE-COUNT
ELSE
IF MARITAL-CODE = "S" OR
MARITAL-CODE = "D" OR
MARITAL-CODE = "W" THEN
ADD 1 TO PEOPLE-COUNT
END-IF
END-IF