Return Values

A procedure that returns a value is essentially a user-defined function, similar to a built-in function. To define a return value for a subprocedure, you must
  1. Define the return value on both the prototype and procedure-interface definitions of the subprocedure.
  2. Code a RETURN operation with an expression that contains the value to be returned.
Start of changeYou define the length and the type of the return value on the procedure-interface specification (the DCL-PI statement, or the definition specification with PI in positions 24-25). The following keywords are also allowed:
DATFMT(fmt)
The return value has the date format specified by the keyword.
DIM(N)
The return value is an array with N elements.
LIKE(name)
The return value is defined like the item specified by the keyword.
LIKEDS(name)
The return value is a data structure defined like the data structure specified by the keyword.
LIKEREC(name{,type})
The return value is a data structure defined like the record name specified by the keyword.
PROCPTR
The return value is a procedure pointer.
TIMFMT(fmt)
The return value has the time format specified by the keyword.
End of change

Start of changeTo return the value to the caller, you must code a RETURN operation with an expression containing the return value. The operand of the RETURN operation is subject to the same rules as an expression with EVAL. The actual returned value has the same role as the left-hand side of the EVAL expression, while the operand of the RETURN operation has the same role as the right-hand side. You must ensure that a RETURN operation is performed if the subprocedure has a return value defined; otherwise an exception is issued to the caller of the subprocedure.End of change