TACL Reference Manual

Expressions
HP NonStop TACL Reference Manual429513-018
3-2
Arithmetic Operations
String operators that include an exclamation point (!) are case-sensitive; those without
exclamation points make no distinction between uppercase and lowercase letters.
The apostrophes around each string operator are part of each operator and must be
present.
Arithmetic Operations
TACL supports arithmetic operations on integers. As with integer-based arithmetic in
other languages, perform multiplication operations before division operations to obtain
the greatest precision.
Logical Operations
TACL supports logical operations and comparisons for integer and string operands.
TACL interprets 0 as FALSE and nonzero integers as TRUE, and typically returns -1 or
1 as the nonzero (TRUE) result for built-in function results. String comparison
operators are enclosed in single quotes to differentiate them from numeric operators.
For example, assuming STATE is a variable containing text and COUNT is a variable
containing a number, this #IF condition could be stated:
[#IF STATE '=' "DONE" OR COUNT = 10 |THEN| ...
String comparison and numeric comparison yield different results. If, for example, one
variable contains 10 and the other contains 010, the two values are equal numerically
but unequal in the string sense (they are = but are not '=').
To perform operations interactively, use the COMPUTE command. To obtain the value
of an expression for use by other code, use the #COMPUTE built-in function. Note,
however, that if a function accepts an expression as an argument, you do not need to
specify #COMPUTE. For example, this statement evaluates the embedded arithmetic
expression because the #IF function accepts an expression as an argument:
[#IF A+1 = 3 |THEN|
...
]
To obtain the value of an expression, use the COMPUTE command (interactive) or the
#COMPUTE built-in function (programmatic).
'=' or '!' Equal to Relational (strings) 3
'<>' or '!<>' Not equal to3 Relational (strings) 3
AND AND Logical 4
OR OR Logical 5
Table 3-1. TACL Operators (page2of2)
Operator Function Type of Operation Precedence