ABORT Statement

Halts program execution, optionally displays a message from the system message file, and terminates the driving Proc.

Syntax

ABORT {message-id {,parameter} ...}

Syntax elements

message-id The item-id of the item containing the message in the system message file (ERRMSG). If the specified item cannot be found, the item-id is displayed, followed by any parameters supplied; see Example 3.

parameter An expression that evaluates to a string to be included in the error message; each parameter replaces an A, A(n) or R(n) message format code in the error message item.

Comments

ABORT functions in the same way as the STOP statement, except that it will terminate a driving Proc.

Example 1

IF COUNT < 10 THEN GOTO 100
PRINT "PROGRAM OVER"
ABORT

If COUNT = 10, the program terminates with the message PROGRAM OVER. In this example, STOP would be a better choice of statements than ABORT, unless the program is being driven by a Proc and you also want to terminate the Proc. Also, in the above example, the PRINT statement is redundant. You could eliminate one line of code by making the last line:

ABORT "PROGRAM OVER"

Example 2

Item '300' in 'ERRMSG' file:

E Program terminated.

DataBasic example:

IF COUNT < 10 THEN GOTO 100
ABORT 300

If count = 10, the program terminates with the message [300] Program terminated.

Example 3

ERR = "Invalid message id"
OPEN "TESTFILE" TO "TEST" ELSE ABORT ERR

If TESTFILE cannot be opened, the program displays the message ERRMSG [Invalid message id]  and terminates.