The general format of the EVALUATE Statement is as follows :
Syntax:
EVALUATE
WHEN condition-1
Statement-1
...
Statement-2
...
WHEN OTHER
Statement-n
...
END-EVALUATE
STATEMENT-X
Interpretation:
The EVALUATE computes the value of the main expression.
1. If the value satisfies condition-1, then Statement-1 is performed, and after execution, control jumps to STATEMENT-X(Outside the EVALUATE Block).
2. Else If the value satisfies condition-2, then Statement-2 is performed, and after execution, control jumps to STATEMENT-X(Outside the EVALUATE Block).
...
n. If the values satisfies none of the above conditions, then by default WHEN OTHER case is executed(Statement-n), and then the control jumps to STATEMENT-X.(Outside the EVALUATE Block)
Thus, at each level of the EVALUATE block, the condition is checked, if it holds true, the case is executed, if it doesn’t hold true, you descend to the next lower level and so on... This is called a fall-through.
Example:
Upon running the above COBOL Program, you should get the following output-
No comments:
Post a Comment
Please Provide your feedback here