COBOL Manual for TNS/E Programs (H06.03+)

Procedure Division Verbs
HP COBOL Manual for TNS/E Programs520347-003
9-71
EXIT
Usage Considerations:
EXIT PROGRAM Statement in a Program That Was Not Called
If a program that was not called by another program executes an EXIT PROGRAM
statement, program execution continues with the next executable statement.
EXIT PROGRAM Statement in a Called Initial Program
If an initial program that was called by another program executes an EXIT
PROGRAM statement, the called program is cancelled (see CANCEL).
EXIT PROGRAM Statement in a Called Program That is Not Initial
If a program that was called by another program and is not initial executes an EXIT
PROGRAM statement, program execution continues with the executable statement
following the CALL statement in the calling program.
The program state of the calling program is the same as it was when it executed
the CALL statement, except for possible changes in the contents of data items and
files that the calling and called programs shared.
The only change in the program state of the called program is that the ends of the
ranges of all PERFORM statements that it executed are considered to have been
reached.
EXIT PERFORM in Nested In-Line PERFORM Statements
An EXIT PERFORM statement in a nested in-line PERFORM statement causes
the innermost PERFORM statement to be exited.
* Y counts to 4, so that every 4th time, exit the perform
* cycle without incrementing Z ...
ADD 1 TO Y
IF Y = 4
MOVE 0 TO Y
EXIT PERFORM CYCLE
END-IF
* so Z is incremented only 75 times, not 100.
ADD 1 TO Z
END-PERFORM
.
DISPLAY "X: " X.
DISPLAY "Y: " Y.
DISPLAY "Z: " Z.
Example 9-22. EXIT PERFORM CYCLE Statement (page 2 of 2)