Outline Perform Until
Outline Perform Until Example
Scenario - Displaying loop iterations using outline PERFORM...UNTIL.
Code -
----+----1----+----2----+----3----+----4----+----5----+
IDENTIFICATION DIVISION.
PROGRAM-ID. PERFOUNT.
AUTHOR. MTH.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-I PIC 9(01) VALUE 1.
PROCEDURE DIVISION.
DISPLAY "Before PERFORM UNTIL".
PERFORM 1000-ITERATION
THRU 1000-EXIT
UNTIL WS-I > 3
DISPLAY "After PERFORM UNTIL".
STOP RUN.
1000-ITERATION.
DISPLAY "WS-I: " WS-I
COMPUTE WS-I = WS-I + 1
1000-EXIT.
EXIT.
Output -
Before PERFORM UNTIL WS-I: 1 WS-I: 2 WS-I: 3 After PERFORM UNTIL
Explaining Example -
In the above example:
- It is a outline PEFORM UNTIL loop that iterates the loop until WS-I greater than 3.
- It displays the iteration number each time before incrementing it.