MODULE 7: COBOL Control statements
PERFORM TIMES
- This format is used when you want to execute set of instruction specific number of times
- Syntax:-
PERFORM [para-1 [{THRU/THROUGH} para-n]] N TIMES
[statement-block END-PERFORM]
Where,
- para-1, para-n are paragraph names which we want to call
- N is the numeric literal or numeric data item to indicate how many times we want to execute the said paragraphs
- [statement-block END-PERFORM] is used for Inline PERFORM.
- This format is used when you want to execute set of instruction N number of times
- Example:-
In PROCUEDURE DIVISION,
PARA-0.
DISPLAY 'IN PARA-0'
PERFORM PARA-1 THRU PARA-1-EXIT 3 TIMES.
DISPLAY 'IN PARA-0 AGAIN'
STOP RUN.
PARA-1.
DISPLAY 'IN PARA-1'.
PARA-1-EXIT.
SYSOUT display (output):-
IN PARA-0
IN PARA-1
IN PARA-1
IN PARA-1
IN PARA-0 AGAIN