pTAL Guidelines for TAL Programmers
Coding Guidelines
pTAL Guidelines for TAL Programmers—527256-002
2-49
Returning a Condition Code
The TAL compiler recognizes the RETURNSCC attribute, accepts the extended syntax
of the RETURN statement, and sets the condition code according to the value you
specify.
In pTAL, both cc_expression and the RETURNSCC attribute are required if either
is present.
Returning a Condition Code
Guideline: The value returned for the condition code in pTAL is not always the same
as in TAL.
In TAL, the value of the condition code returned by a function depends on how the
function value is pushed onto the stack. For example, if a function returns a single byte
by loading its value to the stack, the condition code is set according to whether the
value of the byte in the ASCII collating sequence represents a number (CCL), an
alphabetic character (CCE), or a special character (CCG).
In pTAL, the value of the condition code returned by a function that does not specify
the RETURNSCC attribute is based only on the numeric value returned by the
function. You can test the value of the condition code following a call to a function that
does not specify RETURNSCC only if the value returned is type INT, INT(32),
UNSIGNED, or FIXED. For example, Example 2-62
on page 2-50 calls functions p and
q using a CALL statement. You can test the condition code following the call to p
because the value returned by p is type INT. You cannot test the condition code
following the call to q because q is type REAL.
Example 2-61. RETURNSCC Procedure Attribute
PROC p CALLABLE, RETURNSCC;
BEGIN
INT i;
...
RETURN ,i;
END;
Note. The EpTAL compiler issues a warning if a procedure that uses the RETURNSCC
attribute returns both a traditional function value and a condition code value by means of the
RETURN statement. For details, see the pTAL Reference Manual.