Function
The EXIT statement provides a general exit at the end of a series of procedures.
Format
EXIT.
Syntax rules
The EXIT statement must be preceded by a paragraph-name. It must be the only statement in the paragraph.
The EXIT statement is used only to assign a procedure-name to a given point in the program. It has no other effect on the execution of the program.
General rules
The EXIT statement, when supplied at the end of a series of procedures, enables the normal execution of that sequence of procedures to be interrupted, passing control directly to the end of the procedure sequence.
If control reaches an "EXIT paragraph" and no associated PERFORM or USE statement is active, then control passes to the first sentence of the next paragraph.
Example 8-38
PROCEDURE DIVISION. ... PERFORM X-PAR THRU Y-PAR. ... X-PAR. ... IF A IS ZERO, GO TO Y-PAR. ... Y-PAR. EXIT. Z-PAR. ...
Here, the "EXIT paragraph" is the last procedure covered by the PERFORM statement. If the value of A is zero, then the GO TO statement interrupts the normal flow of execution of the statements ranging from X-PAR to Y-PAR, and passes control directly to the end of the range of procedures specified by the PERFORM statement. After this, program execution resumes with the next statement after PERFORM.