pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
Example 180 Function With RETURNSCC
INT i;
BEGIN
INT cc_result;
...
cc_result :=
IF i < max_val THEN -1
ELSE
IF i = max_val THEN 0
ELSE 1;
RETURN i, cc_result; ! Return a function value and a
END; ! condition code that indicates
! whether the function value is
! less than, equal to, or
! greater than some maximum
NOTE: The EpTAL compiler issues a warning whenever a pTAL procedure returns both a traditional
function value and a condition code value. For details, see Appendix D (page 528).
A function or procedure that specifies RETURNSCC must include cc-expression on every
RETURN statement. Conversely, specify cc-expression in RETURN statements only in functions
and procedures that specify RETURNSCC.
You can test the condition code returned by a function, even if you call the function in a CALL
statement.
Example 181 Condition Code Returned by Function Called by CALL Statement
INT PROC p1(i);
INT i;
BEGIN
RETURN i;
END;
INT PROC p2(i) RETURNSCC;
INT i;
BEGIN
INT j := i + 1;
RETURN i, j;
END;
CALL p1(1);
IF < THEN ...
CALL p2(1);
IF < THEN ...
NOTE: The EpTAL compiler issues a warning whenever a pTAL procedure returns both a traditional
function value and a condition code value. For details, see Appendix D (page 528).
RETURN 227