onerr Clause

The onerr clause identifies the statements to execute when an error occurs during statements that perform operations on peripheral storage devices.

Syntax

onerr statement.block

Description

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

The onerr clause 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.

Example(s)

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

readt tape.rec onerr

crt "oops. we've got a system(0) error of " : system(0)

end

This example illustrates how processing for an error could be divided out based upon the error that occurred.

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

See Also

else Clause, readt Statement, readtx Statement, rewind Statement, Statement Blocks, system() Function, t-att Command, then Clause, then/else Statement Blocks, weof Statement, writet Statement