EXIT Statement [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation
HP COBOL II/XL Reference Manual
EXIT Statement
The EXIT statement provides a common end point for a series of
procedures.
Syntax
paragraph-name.
EXIT.
paragraph/section-name.
Paragraph-name and paragraph/section-name are not a part of the EXIT
statement. They are shown to clarify the fact that:
* EXIT must appear in a sentence by itself.
* EXIT must be the only sentence in a paragraph.
An EXIT statement serves only to enable you to terminate a procedure and
has no other effect on the compilation or execution of the program.
Example
PROCEDURE DIVISION.
:
PERFORM FIX-IT THRU OUT.
:
PERFORM EXCESS THRU OUT.
:
FIX-IT.
IF CHARS IS ALPHABETIC THEN GO TO OUT.
:
EXCESS.
IF OVER-AMT IS EQUAL TO 0 THEN GO TO OUT.
:
OUT.
EXIT.
NEXT-PAR.
:
In the above illustration, both of the IF statements are the first lines
of procedures executed by PERFORM statements. If the condition in either
of the IF statements returns a "true" value, the statement branches to
the OUT paragraph, the EXIT statement is executed, and control passes to
the statement following the PERFORM statement that called the procedure.
MPE/iX 5.0 Documentation