pTAL Reference Manual (H06.08+)
Statements
HP pTAL Reference Manual—523746-006
12-37
Condition Codes
Condition Codes
A procedure (but not a function) returns a condition code only if the procedure
declaration includes the RETURNSCC attribute. The compiler reports an error if a
procedure attempts to test the condition code after calling a procedure that does not
specify RETURNSCC.
Example 12-38 on page 12-37 is similar to Example 12-37 on page 12-37, but is
syntactically correct because p specifies RETURNSCC and returns a condition code
value.
Example 12-36. RETURN Statement in a Procedure That Returns a Condition
Code
PROC p (s, x, y) RETURNSCC;
INT .s, x, y;
BEGIN
INT cc_result;
INT i;
i := x + y;
IF $OVERFLOW THEN cc_result := 1
ELSE cc_result := 0;
s := i;
RETURN cc_result; ! If overflow, condition code is >;
END; ! otherwise, it is =
Example 12-37. Procedure Without RETURNSCC
PROC p;
BEGIN
END;
PROC q;
BEGIN
CALL p;
IF < THEN ... ! ERROR: p did not return a condition code
! or a return value
END;
Example 12-38. Procedure With RETURNSCC (page 1 of 2)
PROC p RETURNSCC;
BEGIN
INT i;
...
RETURN i;
END;










