XFA Specification
Chapter 23, FormCalc Specification
Grammar and Syntax
824
A While Expression is particularly well suited to situations in which conditional repetition is needed.
Conversely, situations in which unconditional repetition is needed is often best dealt with using a
for
expression.
Return
The result of the list of expressions associated with the do condition.
Example
The following example shows pi being computed to two decimal places:
var i = 0.0
while ( Cos(i) gt Sin(i) ) do
i = i + .1
endwhile
while ( Cos(i) lt Sin(i) ) do
i = i - .01
endwhile
i * 4
Block Expressions, Explicit and Implied
In
FormCalc,
the regions of a script where variables can be declared constitute a
block.
All but one of these
expressions are implicit, which means that the block is a side-affect of another expression. The syntax of
the explicit block expression is described in
“Block Expression” on page 825
The entire script constitutes one block, but other expressions declare the beginnings and endings of a
block, which means that blocks can be nested. The following expressions define blocks.
Expressions that define blocks
Expression
Block Expression
If Expressions
Beginning
do
then
elseif
else
For Expressions
For Each Expressions
While Expression
User-Defined Functions
do
do
do
do
End
end
else | endif (whichever comes first)
elseif | else | endif (whichever comes first)
endif (whichever comes first)
endfor
endfor
endwhile
end
This all leads to the following rule regarding variables, and their scope:
A variable declared within block
A
is only valid within its scope in block
A.
If block
B
is nested within block
A,
then a variable valid in block
A
is also valid in block
B
except in a
scope of block
B
where that variable has been redeclared.
Home Index Bookmark Pages
Pages: Home Index All Pages