XFA Specification
Chapter 23, FormCalc Specification
Grammar and Syntax
825
Consider the following annotated FormCalculation as a valid, though contrived example of the concepts
defined above.
Example 23.2 Code blocks determine span of declarations
D = 0;
assign object D the value 0.
var A = 1; declare variable A (scope 1) and assign it the value 1.
var B = 2; declare variable B (scope 1) and assign it the value 2.
var C = 3; declare variable C (scope 1) and assign it the value 3.
func MyFunction(param1) do param1*param1 endfunc ; declare a function
if (D < A) then
var A = -1; re-declare variable A (scope 2)and assign it the value -1.
func MyFunction(param1) do param1/2 endfunc ; re-declare a function
MyFunction(A) ; invoke second user-defined function
if (A < B) then
var A = B + 2;
re-declare variable A (scope 3) and assign it the value 4.
D = D + A; assign object D the value 4 (= 0 + 4).
endif
var B = -2; re-declare variable B (scope 2) and assign it -the value 2.
C = A - B; assign variable C in scope 1, the value 1 (= -1 - -2).
if (A > B) then
var B = A + 2;
re-declare variable B (scope 4) and assign it the value 1.
D = D + B; assign object D the value 5 (= 4 + 1).
endif
var C = A + B; re-declare variable C (scope 2) and assign it the value -3.
D = D + C; assign object D the value 2.
endif
A + B + C + D; the sum is 6 (= 1 + 2 + 1 + 2).
MyFunction(A) ; invoke original user-defined function
Block Expression
98 BlockExpression ::= 'do' ExpressionList 'end'
The block expression defines the scope for an expression list. A scope specifies the lifetime of variables
that it defines. For example, the following expression returns “3”.
var xxx=3 do var xxx=1 end xxx
Function and Method Calls
Function Calls
99 Expression ::= FunctionCall | ...
100 FunctionCall ::= Function '(' ( ArgumentList )
?
')'
101 Function ::= Identifier
102 ArgumentList ::= SimpleExpression (',' SimpleExpression )
*
FormCalc
supports a large set of built-in functions to do arithmetic, financial, logic, date, time, and string
operations. It also allows you to define your own functions.
Here's a summary of the key properties of built-in functions:
Function names are case-insensitive.
Home Index Bookmark Pages
Pages: Home Index All Pages