To return from a function, the RETURN statement syntax is:
|
The value returned to the function reference is the value of the expression specified, converted to conform to the attributes specified in the RETURNS option of the ENTRY or PROCEDURE statement at which the function was entered. For example:
F: procedure returns(fixed bin(15));
·
·
·
G: entry returns(fixed dec(7,2));
·
·
·
dcl D fixed bin(31);
·
·
·
return (D);
If this function was entered at F, then D is converted to the attributes specified in the RETURNS option for the procedure F (FIXED BIN(15)). But, if this function was entered at G, then D is converted to the attributes specified in the RETURNS option for the entry G (FIXED DEC(7,2)).
You cannot specify an expression for the RETURN statement in a begin-block.