HELPLIB.HLB  —  EXIT
    Terminates processing of a command procedure or subroutine
    and returns control to the calling command level-either an
    invoking command procedure or interactive DCL. The EXIT command
    also terminates an image normally after a user enters Ctrl/Y
    (executing another image has the same effect).

    Format

      EXIT  [status-code]

1  –  Parameter

 status-code

    Defines a numeric value for the reserved global symbol $STATUS.
    You can specify the status-code parameter as an integer or an
    expression equivalent to an integer value. The value can be
    tested by the next outer command level. The low-order 3 bits
    of the value determine the value of the global symbol $SEVERITY.

    If you specify a status code, DCL interprets the code as a
    condition code. Note that even numeric values produce warning,
    error, and fatal error messages, and that odd numeric values
    produce either no message or a success or informational message.

    If you do not specify a status code, the current value of $STATUS
    is saved. When control returns to the outer command level,
    $STATUS contains the status of the most recently executed command
    or program.

2  –  Examples

    1.$ EXIT 1

      The EXIT command in this example exits to the next higher
      command level, giving $STATUS and $SEVERITY a value of 1.

    2.$ ON WARNING THEN EXIT
      $ FORTRAN 'P1'
      $ LINK 'P1'
      $ RUN 'P1'

      The EXIT command in this example is used as the target of an
      ON command; this statement ensures that the command procedure
      terminates whenever any warnings or errors are issued by any
      command in the procedure.

      The procedure exits with the status value of the command or
      program that caused the termination.

    3.$ START:
      $        IF (P1 .EQS. "TAPE") .OR. (P1 .EQS. "DISK") THEN GOTO 'P1'
      $        INQUIRE P1 "Enter device (TAPE or DISK)"
      $        GOTO START
      $ TAPE: !  Process tape files
         .
         .
         .
      $        EXIT
      $ DISK:  ! Process disk files
         .
         .
         .
      $        EXIT

      The command procedure in this example shows how to use the
      EXIT command to terminate different command paths within the
      procedure. To execute the procedure, you must enter either TAPE
      or DISK as a parameter. The IF command uses a logical OR to
      test whether either of these strings was entered. If the result
      is true, the GOTO command branches to the corresponding label.
      If P1 was neither TAPE nor DISK, the INQUIRE command prompts
      for a correct parameter.

      The commands following each of the labels TAPE and DISK provide
      different paths through the procedure. The EXIT command before
      the label DISK ensures that the commands after the label DISK
      are executed only if the procedure explicitly branches to DISK.

      Note that the EXIT command at the end of the procedure is not
      required because the end of the procedure causes an implicit
      EXIT command. Use of the EXIT command, however, is recommended.

    4.$ IF P1. EQS. "" THEN -
           INQUIRE P1 "Enter filespec (null to exit)"
      $ IF P1 .EQS. "" THEN EXIT
      $ PRINT 'P1'/AFTER=20:00/COPIES=50/FORMS=6

      The command procedure in this example tests whether a parameter
      was passed to it; if the parameter was not passed, the
      procedure prompts for the required parameter. Then it retests
      the parameter P1. If a null string, indicated by a carriage
      return for a line with no data, is entered, the procedure
      exits; otherwise, it executes the PRINT command with the
      current value of P1 as the input parameter.

    5.$ IF P1 .EQS. "" THEN INQUIRE P1 "Code"
      $ CODE = %X'P1'
      $ EXIT CODE

      The command procedure in this example, E.COM, illustrates
      how to determine the system message, if any, associated with
      a hexadecimal system status code. The procedure requires a
      parameter and prompts if none is entered. Then it prefixes the
      value with the radix operator %X and assigns this string to
      the symbol CODE. Finally, it issues the EXIT command with the
      hexadecimal value. The following example uses the procedure
      E.COM:

        $ @E 1C
        %SYSTEM-F-EXQUOTA, exceeded quota

      When the procedure exits, the value of $STATUS is %X1C, which
      equates to the EXQUOTA message. Note that you can also use
      the F$MESSAGE lexical function to determine the message that
      corresponds to a status code.

    6.$ RUN MYPROG
 <Ctrl/Y>

      $ EXIT

      In this interactive example, the RUN command initiates
      execution of the image MYPROG.EXE. Then pressing Ctrl/Y
      interrupts the execution. The EXIT command that follows calls
      any exit handlers declared by the image before terminating
      MYPROG.EXE.
Close Help