STOP Statement

The STOP statement terminates or suspends the program.

Format 1

STOP RUN [ {RETURNING} return-value ]
           {GIVING   }

Format 2

STOP literal

Format 3

STOP THREAD [ thread-id ]

Syntax Rules

  1. return-value must be a numeric literal or data item.
  2. literal is a numeric or alphanumeric literal.
  3. thread-id must be a USAGE HANDLE or HANDLE OF THREAD data item.
  4. If a STOP RUN statement is in a consecutive sequence of imperative statements in a sentence, it must be the last statement in that sequence. Any statements after STOP RUN in a sentence will not execute.
  5. The optional word GIVING or RETURNING may be specified before the return value in a STOP RUN statement. In this context, GIVING and RETURNING are merely commentary.

General Rules

  1. A Format 1 STOP RUN statement terminates the program. Any files in the open mode are closed. This is done just as if they were the object of a CLOSE statement with no options.
  2. A Format 2 STOP literal statement suspends execution of the program and passes control to the ACUCOBOL-GT debugger. The debugger prints the literal on the screen before accepting debugging commands. Note, however, that you cannot do source level debugging unless you compiled with the -Zd option and run with the -d option.
  3. If return-value is specified, then it is assigned to the special register RETURN-CODE before the program is exited. This special register is defined as:

    It is implicitly shared by all programs of a run unit and is automatically created by the compiler. The final value of RETURN-CODE is returned to the host operating system when the run unit completes.

  4. A Format 3 STOP THREAD statement cancels (destroys) a thread. thread-id identifies the thread to cancel. If thread-id is omitted, the currently executing thread is canceled. If the current thread is the only thread, the STOP THREAD statement behaves like STOP RUN, except that it shuts down the runtime even if there are nested run units (see CALL RUN).