TACL Reference Manual

Built-In Functions and Variables
HP NonStop TACL Reference Manual429513-018
9-71
#COMPUTE Built-In Function
#COMPUTE Built-In Function
Use #COMPUTE to obtain the value of an arithmetic expression.
expression
is an expression using integer values and variable levels, arithmetic operators, and
logical operators, as defined in Section 3, Expressions.
Result
#COMPUTE returns the result of expression; that value can be assigned to a
variable level.
Logical and comparison operators return -1 if the test is true, 0 if the test is false.
Consideration
#COMPUTE performs integer arithmetic; consequently, it discards any fractional part
resulting from division. For example, #COMPUTE 2 / 3 yields a zero result.
Example
1. This routine computes the sum of two numbers:
?SECTION compute^nums ROUTINE
#FRAME
#PUSH a b c
#SETMANY a b, 1 2
#SET c [#COMPUTE a + b]
#OUTPUTV c
2. The routine produces this output:
12> compute^nums
3
13>
#COMPUTE expression