HP OpenVMS DCL Dictionary


Previous Contents Index


RETURN

Terminates a GOSUB subroutine procedure and returns control to the command following the calling GOSUB command.

Format

RETURN [status-code]


Parameter

status-code

Defines a longword (integer) value or expression equivalent to an integer value that gives the exit status of the subroutine by defining a numeric value for the reserved global symbol $STATUS. The value can be tested by the next outer command level. The low-order 3 bits of the longword integer value change the value of the reserved 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.


Description

The RETURN command terminates the GOSUB subroutine and returns control back to the command following the calling GOSUB command.

When a DCL command, user program, or command procedure completes execution, the command interpreter saves the condition code value in the global symbol $STATUS. The system maintains this value in hexadecimal. If a RETURN command does not explicitly set a value for $STATUS, the command interpreter uses the current value of $STATUS to determine the error status.

The low-order 3 bits of the status value contained in $STATUS represent the severity of the condition. The reserved global symbol $SEVERITY contains this portion of the condition code. Severity values range from 0 to 4, as shown in the following table:
Value Severity
0 Warning
1 Success
2 Error
3 Information
4 Severe (fatal) error

Note that the success and information codes have odd numeric values, and that warning and error codes have even numeric values.


Example


$ SHOW TIME 
  15-DEC-2001 14:25:42 
$ GOSUB SYMBOL 
$ EXIT 
$ SYMBOL: 
$     SHOW SYMBOL RED 
      RED = "SET DEFAULT [LOWE.DCL]" 
$     RETURN 1 
      

The GOSUB command transfers control to the subroutine labeled SYMBOL. After the subroutine is executed, the RETURN command transfers control back to the command following the calling GOSUB statement, giving $STATUS and $SEVERITY a value of 1. The procedure then exits.


Previous Next Contents Index