The STOP statement terminates the program and returns the user to the calling environment.
Format
STOP [errmsg [,parameter1, parameter2, ...] |
Parameter(s)
errmsg |
An integer corresponding to an error message from the system message file (ERRMSG). The message is output upon termination of the program. See the "Command Reference" section for a list of these messages. |
parameter1, parameter2, ... |
Parameters passed to the error message. |
Description
The STOP statement terminates program execution and returns system control to the calling environment, which can be a menu, another mvBASIC program, or a Proc. When an error message is specified, it is printed on the terminal screen before the STOP statement is executed, with the specified parameters inserted.
The STOP statement may be used in any part of a program, generally at the logical end of a program or in the ELSE part of a file I/O, tape I/O, floppy disk I/O, or communications statement.
To stop the program and return directly to TCL, use the ABORT statement.
Example
This example demonstrates how the STOP statement may be used to terminate a program when it fails to locate a file item.
READ CUST.REC FROM CUSTFILE,ID ELSE PRINT "ITEM " : ID :" NOT FOUND!" STOP END . . . |
In the next example, the STOP statement is used to signify the end of program execution. The text below the STOP is not executed directly as part of the program sequence but may be accessed through GOTO or GOSUB statements. At runtime the program stops at the STOP statement, but the source lines have been compiled and may be executed nonsequentially.
. . . GOSUB ADDEMUP . . . STOP ADDEMUP: * THIS SUBROUTINE DOES THE COMPUTATION. . . . |
Had an END statement been used instead of a STOP statement, the ADDEMUP routine would not have been compiled.
See Also