ONERR

ONERR


ON ... GOTO Index Level OPEN
Syntax ONERR statement.block
Category BASIC
Type Definition
Description identifies the statements to execute when an error occurs during commands which perform operations on peripheral storage devices.

The "system(0)" function contains the error message associated with the "onerr" condition.

The "onerr" condition is used in the same construct as the "then/else" construct.

Either an "onerr" clause or an "else" clause is allowed in a statement, but not both. They are similar, in that they are taken when the peripheral operation takes a decision-point or failure path. The "onerr" form provides a great deal more functionality, but at a higher cost. When the "onerr" clause exists, all media handling must be handled by the program. This means, for example, that the program is responsible for handling an "end of reel" condition, thus the program would have to prompt the operator for the next reel. By contrast, the "else" clause would handle the same situation by passing through the standard system routine to "mount next reel and press 'c' to continue".
Options
See Also READT READTL READTX THEN THEN | ELSE statement.block statement.block t-att WEOF ELSE WRITET REWIND SYSTEM
Example readt tape.rec onerr
 crt "oops. we've got a system(0) error of " : system(0)
end

In this example, the "onerr" path is taken in the event of any abnormal condition, and it simply displays the value of system(0).

readt tape.rec onerr
   condition = system(0)
   begin case
   case condition = 1
        print "tape is NOT attached..."
   case condition = 5
        print "process end of reel"
   case condition = 6
        print "tape is write-protected"
   end case
end

This example illustrates how processing for an error could be divided out based upon the error which occured.
Warnings If an "onerr" clause appears in the statement, an "else" clause is not allowed.
Compatibility D3 7.0 AP
ON ... GOTO Index Level OPEN