| Introduction | MTB Statements | File System | Compiler | Applications | Reference Guide | Index |
| Language Structure | Data Division | I/O Format Division | Procedure Division | Mnemonics |
| Syntax: | STOP |
| Discussion: |
The STOP statement terminates a program at any point other than
its physical end. Execution of a STOP statement initiates a
termination procedure that closes all open logical unit numbers
and runs the QENDITOR utility program.
There can be more than one STOP statement in a program. Application note: The STOP statement is rarely used due to numerous other ways to terminate program execution. The most common program termination method is running another program via the RUN statement. For unanticipated runtime exception conditions, the ERROR statement is more commonly used. The STOP statement is a runtime statement, as opposed to the END statement which is a compile-time statement indicating the physical end of the source program. |
| Example: |
READ (1,400) EXCP=1000 . . . 1000 IF EXCP NE 33 STOPIn this example, the STOP statement is used in the exception routine at statement-label 1000. In this case, if the system variable EXCP does not equal 33 (which indicates that a record is extracted by another user), the program will stop executing. |