Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]

ON_IOERROR


Syntax | Arguments | Keywords | Examples | Version History | See Also

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.

Syntax

ON_IOERROR, Label

Arguments

Label

Statement to jump to when I/O error is encountered.

Keywords

None.

Examples

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 
   ;If we get here, i is good. 
   VALID = 1 
bad_num: IF ~ valid THEN $ 
         PRINT, 'You entered an invalid number.' 
ENDWHILE 
END 

Version History

Introduced: Original

See Also

CATCH, MESSAGE, ON_ERROR, and Controlling Errors.


Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]