pTAL Reference Manual (H06.08+)
Expressions
HP pTAL Reference Manual—523746-006
5-23
IF
IF
The IF expression selects one of two expressions, usually for assignment to a variable.
condition
is either:
•
A conditional expression
•
An INT arithmetic expression. If the result of the arithmetic expression is not 0,
the condition is true. If the result is 0, condition is false.
expression-1
expression-2
are expressions of any data type, but their data types must be compatible:
•
Every data type is compatible with itself.
•
String and unsigned (1-16) data types are compatible with INT
•
Unsigned (17-32) data types are compatible with INT(32)
•
All fixed-point data types are compatible with each other; however, if
expression-1 and expression-2 are differently scaled fixed-point
expressions, the data type of the CASE expression is the data type of the
fixed-point expression whose scale factor is largest. For example, these return
statements are equivalent:
If condition is true, the result of the expression-1 becomes the result of the
overall IF expression.
If condition is false, the result of expression-2 becomes the result of the overall
IF expression.
int i;
fixed(-2) f2;
fixed(-3) f3;
fixed(-4) f4;
fixed(-2) proc p;
begin
return case i of
begin
f3;
f2;
otherwise f4
end
end
int i;
fixed(-2) f2;
fixed(-3) f3;
fixed(-4) f4;
fixed(-2) proc p;
begin
return case i of
begin
$scale(f3,1);
f2;
otherwise $scale(f4,2)
end
end
condition
THEN
expression-1
ELSE
expression-2
VST014.vsd
IF










