pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

Example 177 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 178 (page 226) is similar to Example 177 (page 226), but is syntactically correct because
p specifies RETURNSCC and returns a condition code value.
Example 178 Procedure With RETURNSCC
PROC p RETURNSCC;
BEGIN
INT i;
...
RETURN i;
END;
PROC q;
BEGIN
CALL p;
IF < THEN ... ! OK: p returns a condition code
END;
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.
Example 179 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;
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.
226 Statements