Access to scripting API

A script expression has access to a subset of the Switch scripting API (application programming interface). In general, a script expression should not have any persistent side-effects; for example it cannot modify the current job or write data to disk. There are two notable exceptions to this rule however: a script expression can log messages and it can update global user data. The following subsections describe in more detail which portions of the scripting API can be accessed from a script expression.

Note:

Do not attempt to violate these limitations (even if Switch inadvertently allows you to do it); the result is undefined and most likely disastrous.

Predefined variables

A script expression can use the following predefined global variables:


Flow element module

Entry points are not supported (instead the main body of a script expression is evaluated to obtain a value).

The Environment class is included except for the following functions: copy, getApplicationPath, getApplicationLicense, findRegisteredApplication, findApplicationOnDisk, getSecondsLeft, sleep.

The Switch class is included except for the following functions: getScriptName, getIn/OutConnections, getJobsForConnection, createNewJob, failProcess, set/getTimerInterval.

The Connection class is excluded.

The Job class is included, but only its functions named "log", "get…" or "is…" are included. This includes functions for logging, getting job file/folder information, getting job ticket info, getting read-only metadata datasets, and evaluating variables. All other functions are excluded.

Metadata module

This module is fully included except for the functions for updating properties.

Specifically, the Map class, the Dataset class and all its subclasses for the supported data models are included, except for the functions for updating properties in the XMP data model.

The CP2 (Certified PDF2) data model is now a part of the Metadata module. It includes the Session class, Certificate class, User class, DataMap class and AltText class.

Utility module

The File class is included but its access mode is limited to read-only. All functions named "remove…" and "write…" are excluded.

The Dir class is included but it is limited to read-only functions. Specifically, all functions named "mkdir…", "rmdir…" and "setCurrent" are excluded.

The Process class is excluded.

XML module

The Document class is included but it is limited to read-only functions. Specifically, the functions named "save" and "transform" are excluded.

All other classes in this module (such as the Element class) are fully included.

Network module

This module allows communication with external applications. It is exposed only to the JavaScript language (not to AppleScript and VBScript).

The classes and functions in the Network module support a subset of the SOAP 1.1 communication protocol over HTTP. Switch SOAP class supports two types of attachments:
  • DIME
  • MIME

Database module

This module allows access to external databases via ODBC and SQL. This module is exposed only to the JavaScript language (not to AppleScript and VBScript).

The classes and functions in the Database module offer access to a small but functional subset of the ODBC API. The DataSource class and Statement class are included.