STOP, STOPE, STOPM
Synopsis
STOP [errcode [,val1[,val2]]] STOPE [errcode [,val1[,val2]]] STOPM [message]
Arguments
errcode | Optional — A MultiValue error code; commonly (but not always) specified as a positive integer. The error code can be specified as a literal or as a expression that resolves to a literal value. A non-numeric literal value must be specified as a quoted string. |
val | Optional — A comma-separated list of one or more literal values to insert into the error message corresponding to errcode. These insert values can be specified as literals or as expressions that resolves to a literal value. A non-numeric literal value must be specified as a quoted string. |
message | Optional — An expression that resolves to a literal error message text, specified as a quoted string. |
Description
All forms of the STOP statement are used to terminate program execution and return control to the calling environment. If you specify an argument, these statements return an error message before terminating program execution.
STOP and STOPE return MultiValue error messages. They are nearly functionally identical; both return the specified error code and corresponding error message. STOPE always returns both the error code and the error message. This includes error messages missing val insert values. STOP always returns the error code; it only returns the error message if you have specified at least one of the val insert values required to complete the error message, or if the error message does not require any insert values. For a list of error codes and corresponding error messages, see Error Messages in the Caché MultiValue Commands Reference.
STOPM returns the literal message text specified in message.
When you call an MVBasic routine from a non-MultiValue environment, a STOP statement clears the entire execution stack and either terminates the process or returns to the Terminal prompt.
Examples
The following Windows example shows a common use of STOP as an ELSE clause statement:
foo="c:\foofile"
OPEN foo TO myfile ELSE STOP 201,foo
STOP returns the error message: [201] Unable to open file 'c:\foofile'.
The following examples show the difference between STOPE and STOP when the error message requires an insert value that the command does not provide:
OPEN foo TO myfile ELSE STOPE 201
STOPE returns: [201] Unable to open file ''.
OPEN foo TO myfile ELSE STOP 201
STOP returns: [201]
ABORT and STOP
The ABORT command terminates all program execution and returns to the programming prompt. The STOP terminates the executing routine and returns control to the calling routine.
During debugging, STOP terminates the debugging session. The debugger treats an ABORT as an error condition; the debugger performs a break operation to allow for examination of the condition causing the ABORT.