pTAL Reference Manual (H06.03+)

Statements
HP pTAL Reference Manual523746-005
12-39
Condition Codes
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 12-41. 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, RETURN,
RETURNSCC, and C/C++ on TNS/E.
Example 12-42. Condition Code Based on Numeric Value
INT PROC p(i);
INT i;
BEGIN
...
RETURN i; ! Return i and set the condition code
END; ! based on the numeric value of i