ON_ERROR_GOTO Procedure
Specifies a statement to jump to if an error occurs in the current procedure.
note | If both ON_ERROR and ON_ERROR_GOTO appear before the line in the code that creates the error condition, the ON_ERROR_GOTO takes precedence. |
Usage
ON_ERROR_GOTO, label
Input Parameters
label—The name of a label statement to jump to.
note | Do not put a colon after this parameter. |
Keywords
None.
Discussion
The ON_ERROR_GOTO procedure transfers program control to the point in the program specified by the label parameter after an error occurs. The label parameter specifies a label, which is an identifier followed by a colon. A label may exist on a line by itself. Labels are explained in the PV‑WAVE Programmer’s Guide.
note | The name null has a special use with this procedure. If the label name is null, the effect of ON_ERROR_GOTO is canceled and normal processing continues. |
If an error occurs, an error code is stored in the system variable !Err. In addition, the text of the error message is stored in !Err_String.
Example
This example demonstrates how ON_ERROR_GOTO is used to control program flow after an error is detected.
PRO on_error_goto_ex1
; If an error occurs here, go to the
; statement label Proc1_Failed.
ON_ERROR_GOTO, Proc1_Failed
; The effect of ON_ERROR_GOTO is canceled,
; normal error processing is in effect.
ON_ERROR_GOTO, null
RETURN
Proc1_Failed:
PRINT, !Err, !Err_String
END
See Also