*Conan The Librarian
Performs a specified action when a command or program executed
within a command procedure encounters an error condition or
is interrupted by Ctrl/Y. The specified actions are performed
only if the command interpreter is enabled for error checking or
Ctrl/Y interrupts (the default conditions). Use the ON command
only in a command procedure.
ON condition THEN [$] command
Specifies either the severity level of an error or a Ctrl/Y
interrupt. Specify one of the following keywords, which may be
abbreviated to one or more characters:
WARNING Return status of warning occurs ($SEVERITY equals
ERROR Return status of error occurs ($SEVERITY
SEVERE_ERROR Return status of error occurs ($SEVERITY
CONTROL_Y Ctrl/Y character occurs on SYS$INPUT.
The default error condition is ON ERROR THEN EXIT.
Specifies the DCL command line to be executed. Optionally, you
can precede the command line with a dollar sign ($).
If you specified an error condition as the condition parameter,
the action is taken when errors equal to or greater than the
specified level of error occur.
1.$ ON SEVERE_ERROR THEN CONTINUE
A command procedure that contains this statement continues
to execute normally when a warning or error occurs during
execution. When a severe error occurs, the ON statement signals
the procedure to execute the next statement anyway. Once
the statement has been executed as a result of the severe
error condition, the default action (ON ERROR THEN EXIT) is
2.$ ON ERROR THEN GOTO BYPASS
$ RUN A
$ RUN B
$ RUN C
If either program A or program B returns a status code with a
severity level of error or severe error, control is transferred
to the statement labeled BYPASS and program C is run.
3.$ ON WARNING THEN EXIT
$ SET NOON
$ RUN [SSTEST]LIBRA
$ SET ON
The ON command requests that the procedure exit when any
warning, error, or severe error occurs. Later, the SET NOON
command disables error checking before executing the RUN
command. Regardless of any status code returned by the program
LIBRA.EXE, the procedure continues. The next command, SET ON,
reenables error checking and reestablishes the most recent ON
4.$ ON CONTROL_Y THEN GOTO CTRL_EXIT
$ CLOSE INFILE
$ CLOSE OUTFILE
The ON command specifies action to be taken when Ctrl/Y is
pressed during the execution of this procedure: the GOTO
command transfers control to the line labeled CTRL_EXIT. At
CTRL_EXIT, the procedure performs cleanup operations (in this
example, closing files and exiting).