pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

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:
ExamplesDescriptionExpression
398 + num / 8410 LOR 12An expression, consisting of operands
and arithmetic operators, that
produces a single numeric value.
Arithmetic expression
IF @p + 0 > @q THEN ...
nl
An expression containing relational
and or add and subtract arithmetic
Address expression
IF @p <> 0 THEN ...;
nl
operators. You can use arithmetic
expressions to compute addresses,
IF @p - @q > 5 THEN ...;
compare addresses, or compare them
to a constant.
398 + 46 / 84An arithmetic expression that contains
only constants, LITERALs, and DEFINEs
as operands.
Constant expression
a < c a OR bAn expression establishing the
relationship between values and
Conditional expression
resulting in a true or false value. A
conditional expression consists of
relational conditions and conditional
operators.
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
Topics:
Data Types of Expressions (page 70)
Operator Precedence (page 70)
Arithmetic Expressions (page 72)
Signed Arithmetic Operators (page 73)
Unsigned Arithmetic Operators (page 75)
69