[an error occurred while processing this directive]
HP OpenVMS Systems Documentation |
HP OpenVMS DCL Dictionary
ON
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. FormatON condition THEN [$] command Parameters
DescriptionDuring the execution of a command procedure, the command interpreter checks the condition code returned from each command or program that executes. With the ON command, you can establish a course of action for the command interpreter to take based on the result of the check.
|
#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 reinstated.
#2 |
---|
$ ON ERROR THEN GOTO BYPASS $ RUN A $ RUN B . . . $ EXIT $ BYPASS: $ 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 condition.
#4 |
---|
$ ON CONTROL_Y THEN GOTO CTRL_EXIT . . . $ CTRL_EXIT: $ CLOSE INFILE $ CLOSE OUTFILE $ EXIT |
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).
Previous | Next | Contents | Index |