cobol

EXIT statement

Remarks#

The COBOL EXIT statement is a terminating flow control verb.

EXIT comes is a few flavours:

  • bare EXIT is a common end point for a series of procedures.
  • EXIT PARAGRAPH, EXIT SECTION provides a means of exiting a structured procedure without executing any of the subsequent statements.
  • EXIT FUNCTION, EXIT METHOD, EXIT PROGRAM marks the logical end of a module of code.
  • EXIT PERFORM breaks out of a inline perform loop.
  • EXIT PERFORM CYCLE causes an inline perform loop to begin the next iteration.

enter image description here

EXIT statement

PERFORM VARYING counter FROM 1 BY 1 UNTIL counter > 10
    IF debug-override THEN EXIT PERFORM
    IF counter = 5 THEN EXIT PERFORM CYCLE
    PERFORM some-miracle
END-PERFORM

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow