XFA Specification
Chapter 23, FormCalc Specification
Grammar and Syntax
826
●
Built-in functions are predefined, but their names are not reserved words: this means that the built-in
function Max() will never conflict with an object, object property, or object method named Max.
Many of the built-in functions have a mandatory number of arguments which can be followed by a
optional number of arguments.
Some built-in functions, accept an indefinite number of arguments. Examples of such functions
include:
Avg()
Count()
Max()
Min()
Sum()
Concat()
Built-in functions take precedence over user-defined functions. That is, if the user defines a function
with the same name as a built-in function, the built-in function is executed.
●
●
●
Note:
If you write a function that has the same name (ignoring case) as one of the built-in functions, your
function is NOT invoked. Rather, the built-in function is invoked. FormCalc provides several
undocumented built-in functions: acos, asin, atan, cos, deg2rad, exp, log, pi, pow, rad2deg, sin, sqrt,
and tan.
Method Calls
103 MethodCall ::= Method '(' ( ArgumentList )
?
')'
104 Method ::= Identifier
105 ArgumentList ::= SimpleExpression (',' SimpleExpression )
*
FormCalc
also provides access to object methods, not just objects and object properties. The syntax for
Accessors
90
Adobe XML Form Object Model Reference
[FOM].
Methods are application-defined operators that act upon objects and their properties; these operators are
invoked like a function call, in that arguments may be passed to methods exactly like function calls. The
number and type of arguments in each method are prescribed by each object type. Objects of different
types will support different methods.
Examples
Here are examples of method calls:
v = $.getValue();
$host.MessageBox(1, v);
// retrieve this referencing object's value.
// display it in this host's dialog box.
Case Sensitivity
The names of functions and methods are case insensitive, but are not reserved. This means that
calculations on forms with objects whose names coincide with the names of functions do not conflict; any
object method or function can be called equally.
Argument List
All functions and methods take an ArgumentList
105
, although that list may be empty. The number and
type of arguments varies with each function. Some, such as
Date()
and
Time()
Others, such as
Num2Date()
remaining arguments being strings. Many functions accept a variable number of arguments. Leading
arguments are mandatory, and trailing arguments are often optional. This maintains the complexity of
most functions at a low level. Increased functionality is provided to those users who need it by requiring
them to supply the additional arguments.