TAL Programmer's Guide

RETURN Statement
Controlling Program Flow
12–22 096254 Tandem Computers Incorporated
Returning a Condition Code
As of the D20 release, if result-expression is any type except FIXED or REAL(64), a
function can return a cc-expression and a result-expression. cc-expression is an INT
expression whose numeric value specifies the condition code value to return to the
caller. If the cc-expression is:
Less than 0 Set the condition code to less than (<)
Equal to 0 Set the condition code to equal (=)
Greater than 0 Set the condition code to greater than (>)
The following function returns a result and a condition code to inform its caller that
the returned value is less than, equal to, or greater than some maximum value:
INT PROC p (i);
INT i;
BEGIN
RETURN i, i - max_val; !Return a value and a
END; ! condition code
If you call a function, rather than invoking it in an expression, you can test the
returned condition code:
INT PROC p1 (i);
INT i;
BEGIN
RETURN i;
END;
INT PROC p2 (i);
INT i;
BEGIN
INT j := i + 1;
RETURN i, j;
END;
CALL p1 (i);
IF < THEN ... ; !Test the condition code
CALL p2 (i);
IF < THEN ... ; !Test the condition code