Creating basic calculations. Adobe 6.2
விளம்பரம்
விளம்பரம்
Scripting with FormCalc and JavaScript 6
6.2.2.
Built-in function syntax
Each FormCalc function uses a specific syntax notation that you must follow in order for the function to execute correctly. This table describes, generally, the pieces of syntax notation.
k n d f
Syntax notation
s v n1, n2, n3
[ [ n [, k ] ] ] n1 [, n2 ... ] d [, f [, k ] ]
R
ELATED LINKS
:
Replacement values
A valid date string (for example, 03/15/1996)
A valid date format string (for example, MM/DD/YYYY)
A valid locale identifier (for example, fr_FR)
A valid numeric value. Notice that the range of valid values varies from function to function.
A valid unit of measurement (for example, “in” for inches).
A valid reference syntax.
All values are required.
No values are required, but you can choose to specify just n, or both n and k.
n1 is required, but you can choose to specify an unlimited number of additional values.
d is required, but you can choose to also specify f or both f and k.
6.3.
Creating basic calculations
6.3.1.
About basic calculations
Simple 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.
72
Scripting with FormCalc and JavaScript
6.3.2.
Examples of basic calculations
These 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
"abc"
2 - 3 * 10 / 2 + 7
(10 + 2) * (5 + 4)
0 and 1 or 2 > 1
2 < 3 not 1 == 1
Equivalent to
"abc"
2 - (3 * 10 / 2) + 7
(10 + 2) * (5 + 4)
(0 and 1) or (2 >1)
(2 < 3) not (1 == 1)
Result
abc
-6
108
1 (true)
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
| , or Lowest
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.
73
பதிவிறக்கு
விளம்பரம்