XFA Specification
Chapter 23, FormCalc Specification
Grammar and Syntax
820
Variable V
Reference
Variable e contains
Reference to an object
Null value
Non-null value
var V = e
V = &O
V = null
❑V
= e
V = &O
V = null
V=e
evaluates as …
Non-reference
Reference to an object
Null value
Non-null value
The light grey cells denote variables that result in references, whereas, the yellow cells denote variables
that result in values.
To summarize then, when a variable is been assigned a valid reference, the variable becomes a reference. It
stays a reference until its assigned the null-reference, or goes out of scope. This principle is illustrated in
the following sequence:
var
…
q =
…
q =
q =
…
q =
…
q =
q = 5
Ref(ShipDate)
5
null
Ref(null)
5
// variable q is assigned the value 5.
// q is now a reference to object ShipDate.
// object ShipDate is assigned the value 5.
// object ShipDate is assigned the value null.
// q is now a null-reference.
// variable q is assigned the value 5.
Passing References to Functions
Passing references as arguments to built-in functions involves the pair-wise assignment of the function's
actual arguments to its formal arguments, in which case, the above assignment rules apply.
var p = Ref(Price)
var q = Ref(p)
WalkTheDOM(p)
Passing References to Methods
Passing references as arguments to methods again involves the pair-wise assignment of the method's
actual arguments to its formal arguments, in which case, the above assignment rules apply equally.
Methods are normally defined to take arguments of a given type, but FormCalc references are all untyped,
so the user must ensure that references passed as arguments to methods are of the correct type; runtime
exceptions will ensue if the user does otherwise.
var p = Ref(Price)
$.Clone(p)
Returning References from Methods and Functions
Returning references from methods and functions either involve the assignment of the return value to a
variable or the passing of the return value to another function or method. Both cases are described by the
rules above.
Ref(Quantity)
FindMySiblings(Ref(Quantity))