Adobe acrobat forms javascript object specification User Manual

Page of 64
Acrobat Forms - JavaScript Object Specification
50
Global Object
The Global object is a static JavaScript object that allows you to share data between documents
and have data be persistent across sessions. This is referred to as persistent global data.
Global data-sharing and notification across documents is done through a publish and subscribe
mechanism. This mechanism gives you the ability to monitor global data variables and report
their value changes across documents.
Global data can be specified by adding properties to the global object. The property type can
be a string, a boolean, or a number. For example, to add a variable called “volume” and to
allow all document scripts to have access to this variable, a script would simply define it as:
global.volume = 80;
To delete a variable or a property from the global object, use the delete operator to remove the
defined property. For more information on the reserved JavaScript keyword delete, please see
Netscape’s JavaScript Reference Manual
. For example, to remove the property “volume” from
the global object, call the following script:
delete global.volume
Global Object Methods
setPersistent
parameters: cVariable, bPersist
Returns: none
This method sets cVariable to be persistent. It requires that bPersist is set true. This means the
cVariable will exist across invocations of Acrobat Exchange or Reader. If bPersist is false (the
default for any global property) then the property will be accessible across documents but not
across the Acrobat Viewer sessions. For example, to make the “volume” property persistent
and accessible for other documents you could use:
global.setPersistent("volume", true);
Note:
Persistent global data only applies to variables of type boolean, number or
string. For all persistent data there is a 32k limit for the maximum size of
the global persistent variables. Any data added to the string after the 32k
limit will be dropped.
It is recommended that JavaScript developers building scripts for Acrobat Forms, utilize some
type of naming convention when specifying persistent global variables. One suggestion is to
start all variables with your company name. For example, if your company name is Xyz, start