Return from Subroutine (RTNSUBR)
Where allowed to run:
|
Parameters Examples Error messages |
The Return from Subroutine (RTNSUBR) command returns control to the command immediately following the Call Subroutine (CALLSUBR) command that called the subroutine. The RTNSUBR command must be used within a subroutine, and multiple RTNSUBR commands may be used in a subroutine. If a value is to be returned, such as an error code, the returned value must be able to be stored into a 4-byte signed integer CL variable. The Return value (RTNVAL) parameter can be a variable or constant. If no RTNVAL parameter is defined, the value will default to zero.
Restrictions:
- This command is valid only within a CL subroutine.
Top |
Return value (RTNVAL)
Specifies the value to be returned from the subroutine. This can be a variable or constant that can be stored in a 4-byte signed integer CL variable. If the Call Subroutine (CALLSUBR) command that called the subroutine specified a CL variable for returned value, the variable is set to this value.
- 0
- The subroutine returns a zero.
- integer-constant
- Specify the constant integer value for the return value.
- CL-variable-name
- Specify the name of the CL variable to contain the return value from the called subroutine. This must be a signed integer CL variable.
Top |
Examples
PGM : SUBR SUBR1 : IF (&A *LT 30) THEN(RTNSUBR RTNVAL(-1)) : ENDSUBR ENDPGM
This CL subroutine is exited by the RTNSUBR command if &A is less than 30, with a return value of -1.
Top |
Error messages
None
Top |