About basic calculationsSimple
expressions are the most basic instances of scripting. These expressions do
not involve using FormCalc built-in functions and are never more
than a single line. Add simple expressions to the calculate event
of a particular field or object so that the expression value can
output onto your form.
Examples of basic calculationsThese
examples are all of simple expressions:
2
"abc"
2 - 3 * 10 / 2 + 7
Each simple expression evaluates
to a single value by following a traditional order of operations,
even if the order is not always obvious from the expression syntax.
For example, the following sets of expressions produce equivalent
results.
Expression
|
Equivalent to
|
Result
|
"abc"
|
"abc"
|
abc
|
2 - 3 * 10 / 2 + 7
|
2 - (3 * 10 / 2) + 7
|
-6
|
(10 + 2) * (5 + 4)
|
(10 + 2) * (5 + 4)
|
108
|
0 and 1 or 2 > 1
|
(0 and 1) or (2 >1)
|
1 (true)
|
2 < 3 not 1 == 1
|
(2 < 3) not (1 == 1)
|
0 (false)
|
As implied in the previous table, all FormCalc
operators carry a certain precedence when they appear within expressions.
The following table illustrates this operator hierarchy.
Precedence
|
Operator
|
Highest
|
=
|
|
(Unary) - , + , not
|
|
* , /
|
|
+ , -
|
|
< , <= , > , >= , lt , le ,
gt , ge
|
|
== , <> , eq , ne
|
|
& , and
|
Lowest
|
| , or
|
All the previous examples are valid, simple
expressions that you can add to a form field or object that accepts
calculations and scripts. For example, if you create a form in Designer
with a single numeric field, add the following calculation to the calculate
event in the Script Editor.
Then,
when you click the Preview PDF tab to view the completed form, the
value of the simple expression appears in the text field.
If
the value does not appear in the preview, ensure that your simple
expression appears in the calculate event of the form design object.
Also, ensure that you installed Designer and Acrobat correctly.
|
|
|