VMS Help  —  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.

    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).
Close Help