The OpenVMS DCL command HELP ON EXAMPLE
displays:
ON
Examples
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.
According to the help if neither [-]x.for
nor [-]y.for
exist then the last two lines will not be executed:
$ on error then $ continue
$ rename [-]x.for []
$ rename [-]y.for []
$ type *.for
Is there a way to set the ON ERROR
handling as in the first line w/o placing an ON ERROR
statement between each line of the script?
If the ON ERROR fires, you have to re-establish it. It looks like you don't know whether any of the files exists. So the ON ERROR needs to be re-established after the first failing command.
You can do this in a subroutine, like in:
Also, you can handle this differently, with disabling error checking (SET NOON):
or establishing error handling only for sever errors (ON SEVERE_ERROR):