ON_IOERROR

The ON_IOERROR procedure specifies a statement to be jumped to if an I/O error occurs in the current procedure. Normally, when an I/O error occurs, an error message is printed and program execution is stopped. If ON_IOERROR is called and an I/O related error later occurs in the same procedure activation, control is transferred to the designated statement with the error code stored in the system variable !ERROR_STATE. The text of the error message is contained in !ERROR_STATE.MSG.

The effect of ON_IOERROR can be canceled by using the label "NULL" in the call.

Calling Sequence

ON_IOERROR, Label

Example

The following code segment reads an integer from the keyboard. If an invalid number is entered, the program re-prompts.

i = 0 ; Number to read

valid = 0 ; Valid flag

WHILE valid EQ 0 DO BEGIN

   ON_IOERROR, bad_num

   READ, 'Enter Number: ', i

   VALID = 1 ; If we get here, i is good.

bad_num: IF NOT valid THEN $

         PRINT, 'You entered an invalid number.'

ENDWHILE

END

See Also

CATCH , MESSAGE , ON_ERROR , and Controlling Errors .