pTAL Reference Manual (H06.08+)
Statements
HP pTAL Reference Manual—523746-006
12-38
Condition Codes
Functions that do not specify RETURNSCC return a condition code that is based on
the numeric value returned by the function, regardless of the nature of the expression
in the RETURN statement.
Functions can return a condition code that is independent of the value returned by the
function, as follows:
•
The function declaration must specify the RETURNSCC attribute.
•
Each RETURN statement in the function must specify the value of the condition
code.
PROC q;
BEGIN
CALL p;
IF < THEN ... ! OK: p returns a condition code
END;
Example 12-39. Function Without RETURNSCC
INT PROC p(i);
INT i;
BEGIN
RETURN IF i = 0 THEN -1 ! Returns a condition code
ELSE IF i = 1 THEN 0 ! based on the value returned
ELSE 1
END;
Example 12-40. 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, RETURN,
RETURNSCC, and C/C++ on TNS/E.
Example 12-38. Procedure With RETURNSCC (page 2 of 2)










