pTAL Reference Manual (H06.08+)

HP pTAL Reference Manual523746-006
5-1
5 Expressions
An expression is a sequence of operands and operators that, when evaluated,
produces a single value. Operands in an expression include variables, constants, and
routine identifiers. Operators in an expression perform arithmetic or conditional
operations on the operands. pTAL supports the following types of expressions:
Expressions can appear in:
LITERAL declarations
Variable initialization and assignments
Array and structure bounds
Indexes to variables
Conditional statements
Parameters to procedures or subprocedures
An expression can be:
A single operand, such as the number 5
A unary plus or minus (+ or -) operator applied to a single operand, such as -5
A binary operator applied to two operands, such as 5 * 8
A complex sequence such as:
(((alpha + beta) / chi) * (delta - 145.9)) / zeta
Expression Description Examples
Arithmetic
expression
An expression, consisting of operands and
arithmetic operators, that produces a single
numeric value.
398 + num / 84
10 LOR 12
Address
expression
An expression containing relational operators,
that allows you to compare addresses, or
compare an address to a constant.
IF @p = 0 THEN ...
Constant
expression
An arithmetic expression that contains only
constants, LITERAL
s, and DEFINEs as operands.
398 + 46 / 84
Conditional
expression
An expression establishing the relationship
between values and resulting in a true or false
value. A conditional expression consists of
relational conditions and conditional operators.
a < c
a OR b