Loop Statements in COBOL
COBOL Loop Statements:
In COBOL, Loop Statements are some set of statements in a program that needs to be executed repeatedly, such as reading each record of a file up to its end. These statements in the program are running in a series until or unless any statement executed in the flow alters the execution sequence.
In COBOL, There are mainly four types of loop statements are:
PERFORM THRU:
It performs a series of paragraphs by giving in the sequence the first and last names of the paragraph. After performing the last paragraph, the control will return.
PERFORM UNTIL:
A block of statements or a paragraph/section will be executed in the PERFORM UNTIL statement until the specified condition becomes true.
The default condition is ‘WITH TEST BEFORE‘ and it defines that the condition is tested before the execution of statements in a paragraph.
PERFORM TIMES:
It specifies the number of times a paragraph should be executed.
PERFORM VARYING:
In perform varying, a paragraph will be executed till the condition in Until phrase becomes true.