TAL Programmer's Guide

RETURN Statement
Controlling Program Flow
096254 Tandem Computers Incorporated 12–23
The following procedure returns a condition code that indicates whether an add
operation overflows:
PROC p (s, x, y);
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
END; ! is >; otherwise, it is =
Returning From
Nonfunction Procedures
In procedures and subprocedures that are not functions, a RETURN statement is
optional. If you include a RETURN statement, it cannot return a result.
The following procedure returns control to the caller when A is less than B:
PROC something;
BEGIN
INT a,
b;
!Manipulate A and B
IF a < b THEN
RETURN; !Return to caller
!Lots more code
END;
To return a condition code value, a nonfunction procedure or subprocedure must use
a RETURN statement that includes cc-expression.
In a main procedure, a RETURN statement stops execution of the program and returns
control to the operating system.