TAL Reference Manual

Statements
TAL Reference Manual526371-001
12-32
Usage Considerations
cc-expression
is an INT expression whose numeric value specifies the condition code value to
return to the caller. If
cc-expression is:
result-expression
is an arithmetic or conditional expression that a function must return to the caller.
result-expression must be of the same return type as the data type specified in the
function header. The data type of a conditional expression is always INT. Specify
result-expression only when returning from a function.
Usage Considerations
In general, a procedure or subprocedure returns control to the caller when:
A RETURN statement is executed.
The called procedure or subprocedure reaches the end of its code.
Returning From Functions
A function is a typed procedure or subprocedure. If a function lacks a RETURN
statement, the compiler issues a warning, but the compilation can complete and the
resulting object file can be run. After the function executes, it returns a zero.
If
result-expression is any type except FIXED or REAL(64), a function can return both
result-expression and cc-expression.
A function can also return the condition code value by specifying a value in a CODE or
STACK statement; however, CODE and STACK statements are not portable to future
software platforms. Furthermore, if the compilers RP counter setting is not correct, the
compiler emits a warning.
Returning From Nonfunction Procedures and
Subprocedures
In procedures and subprocedures that are not functions, a RETURN statement is
optional. A nonfunction procedure or subprocedure that returns a condition code value,
however, must return to the caller by executing a RETURN statement that includes
cc-
expression.
In a procedure designated MAIN, a RETURN statement stops execution of the
procedure and passes control to the operating system.
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 (>)