PERFORM THROUGH | THRU
PERFORM THROUGH|THRU
- PERFORM statement executes a specific paragraph or a range of paragraphs.
- PERFORM...THROUGH (or PERFORM...THRU) specifies a block of consecutive paragraphs to be executed.
- It is an outline PERFORM.
Syntax -
PERFORM paragraph-1 THROUGH paragraph-2
OR
PERFORM paragraph-1 THRU paragraph-2
Parameters -
- paragraph-1 - The starting paragraph to be executed.
- paragraph-2 - The ending paragraph. After executing this paragraph, control returns to the statement following the PERFORM.
Practical Example -
Scenario - Executing paragraphs using PERFORM...THRU.
Code -
----+----1----+----2----+----3----+----4----+
...
PROCEDURE DIVISION.
PERFORM 1000-DISPLAY1
THRU 3000-DISPLAY3.
STOP RUN.
...
1000-DISPLAY1.
DISPLAY "Paragraph1".
2000-DISPLAY2.
DISPLAY "Paragraph2".
3000-DISPLAY3.
DISPLAY "Paragraph3".
4000-DISPLAY3.
DISPLAY "Paragraph4".
OUTPUT -
Before Inline PERFORM...TIMES Iteration: 1 Iteration: 2 Iteration: 3 Iteration: 4 Iteration: 5 Iteration: 6 After Inline PERFORM...TIMES