Scripting overview

Switch offers a comprehensive scripting environment. With limited scripting experience, a user can substantially extend Switch's capabilities and provide for interaction with third-party systems in new and powerful ways.

The various topics in this chapter describe the Switch scripting environment, including its capabilities for working with metadata.

Note:

In addition to Switch's own scripting environment, certain Switch configurators support executing JavaScript scripts inside the Adobe Creative Suite applications. These types of scripts are not discussed in this chapter; instead refer to JavaScript for applications.

Switch supports two types of scripting languages:


Operating system scripting languages

Operating system scripting is intended primarily for communicating with other applications or with operating systems services from within Switch. The supported scripting languages are:


In each environment, a script object representing the Switch application provides access to key variables and functions, including the metadata context of the job being processed.

By definition, operating system scripts are platform-specific (i.e. not portable).

Internal scripting language

The Switch-internal scripting language JavaScript is intended primarily for working with variables and functions provided by Switch (rather than the operating system). A primary goal of the internal scripting language is to work with the contents of metadata fields associated with the jobs being processed.

Switch supports a substantial JavaScript subset (more precisely, it supports a subset of the ECMAScript 4.0 language), with extensions for:


JavaScript scripts have limited "external access". For example, there is no way to communicate with interactive applications, and there is no access to operating system services.

JavaScript scripts are cross-platform, i.e. they work without change on both Mac OS X and Microsoft Windows.

Script element and script expression

A script element is a flow element that encapsulates a script written in any of the supported scripting languages. The script implements an "entry point" function called by Switch for each job being processed through the flow element.

A script expression is a text string associated with a flow element property. To determine the value of the property, Switch evaluates the contents of the string as a JavaScript expression in the context of the job being processed. Only JavaScript is supported in script expressions.

The Switch scripting API (application programming interface) provides script elements and script expressions with access to information about the job being processed, including job ticket and metadata contents. Script expressions are limited to read-only access, while script elements can update the information.

Script package

A script that is to be associated with a script element consists of the following components:


These components are collected in a single file called a "script package" which is presented to the script element as a single entity. This also allows creating "fat" packages containing an implementation of the same functionality on multiple platforms.

Scripted plug-in

A scripted plug-in is a script package that, when saved with the appropriate password and placed in the appropriate folder, behaves just like a tool or configurator built into Switch.

Scripted plug-ins are of no concern to regular Switch users. Enfocus may license selected third-party vendors to develop scripted plug-ins.

Script development

Switch includes a script development environment called SwitchScripter, installed as a separate application with the following major functions: