pTAL Conversion Guide

Statements
pTAL Conversion Guide527302-002
15-16
IF Statement
IF Statement
The IF statement conditionally selects one of two statements to execute.
Topics:
Testing Address Types on page 15-16
Testing Hardware Indicators on page 15-16
Testing INT(32) Variables Without a Not-Equal Operator on page 15-16
Testing Address Types
In both TAL and pTAL, an IF statement can test any 16-bit compatible value—INT,
STRING, or UNSIGNED(1-16)—as if it were a Boolean value. The result of evaluating
an IF statement’s conditional expression must yield a 16-bit result. Valid conditional
expressions are described in Relational Operators and Condition Codes on
page 13-10.
In pTAL, an IF statement can test an EXTADDR variable as if it were a Boolean value.
Testing Hardware Indicators
Native architecture does not have the hardware indicators that TNS architecture does.
Instead, the native compiler emits code that supports the hardware indicators. For
more information, see Section 20, Hardware Indicators.
Testing INT(32) Variables Without a Not-Equal Operator
TAL
You can test an INT variable for a nonzero value without specifying a not-equal
operator; however, the variable tested by the IF statement cannot be an INT(32)
variable.
pTAL
You can also test an INT(32) variable for a nonzero value without specifying the not-
equal operator.
Example 15-21. Testing an INT Variable Without a Not-Equal Operator (TAL)
INT i;
...
IF i THEN... ! OK: same as "IF i <> 0 THEN ..."