Overview

Scripts are procedures that automate the execution of tasks, enabling control of data sources and data points. Scripts don't have a return value, but they allow to set a value to a data point, since it is settable.

JavaScript / ECMAScript

Scripts require some knowledge of JavaScript, also known as ECMAScript. (The full specification for ECMAScript is available here.) JavaScript is arguably the most popular scripting language in use today, it being the only language available for use in every popular web browser. The result is that, by far the common usage of JavaScript is in web pages. The context within the Meta data source is of course different, there being no "window" or "document" objects, among other more subtle differences. Contextual differences aside, a full and complete implementation of ECMAScript is available within this data source. Specifically, the Rhino implementation is used.

Script configuration

The Script context defines the points that will be available to the script when it executes. Each point that is added must be given a Var, which is the variable name the point data will be assigned to in the script. These script var names must be valid ECMAScript variable names: they must start with either a letter or an underscore, and may not contain spaces. Other constraints may apply. You will receive validation or script execution exceptions if script var names are not correctly defined. To add a point to the context, select it from the list and click the icon. To delete an existing point from the context click the icon associated with the point. Points that are not needed in the script should not be added to the context since some overhead is involved in preparing the data for the script. Also, unnecessary script vars may cause unintended script executions. (See "Script execution" below.) However, the contrary may also be true: it may be useful to include a script var in a context in order to cause script execution.

The context objects control data sources and data points. As in context points, a Var name must be set, and the checkbox enables the object to the context.

Script execution

Execution can be manual, by clicking on the icon , or automated, through event handlers. In manual execution, a message will be displayed indicating an error or success. The script must be saved before an execution.