Run Script
Run Script tasks are used to run scripts that typically perform some kind of processing on the job file received by the task. Scripts are often simpler to write than programs added with the External Program action (see External Program). However, they can be slower to execute.
The Run Script task can be used either as an Action or a Condition. When dragging and dropping a Run Script task on a given process, you select whether to use this task as an Action or a Condition from a contextual menu.
For more information on scripts, what languages are supported and how to write scripts and conditions, please see the related chapter, Using Scripts.
Input
Any data file, in any format.
Processing
The script is executed. The script can modify anything such as the data file, Job Info variables, Metadata, or even other files on the operating system.
Output
Whatever file the Run Script action generates, Metadata it modifies or creates, etc.
When using Run Script as a Condition, the output of the task can be within the branch or on the main trunk. To control the output, use the Script.ReturnValue variable in your script.
Properties
The Script Editor menu options are as follows.
- File
- Import: Lets you open an existing script from an external file. This can be a .vbs, .js, .pl or .py file for language-specific scripts, or .txt for any of them.
- Export: Lets you save the current script as a file.
- Print: Prints the current script.
- Edit
- Undo: Undo the last edit.
- Cut: Cut the current selection (only available if there is selected text in the editor).
- Copy: Copy the current selection (only available if there is selected text in the editor).
- Paste: Paste the last selection that was cut or copied in the location of the cursor in the text editor.
- Delete: Delete the current selection (only available if there is selected text in the editor).
- Select All: Select all of the contents of the editor.
- Search
- Find: Brings up the Find dialog.
- Find Again: Repeats the previous search and finds the next occurrence.
- Replace: Brings up the Replace dialog.
- Go To Line: Brings up the Go To Line dialog where you can enter a line number and jump directly to that line.
- Language: Select the language in which your script is written. Choices are VBScript, JavaScript, Perl or Python.
- Tools
- Editor Options...: Opens the Editor Options.
- Help
- Contents and Indexes: Opens the Editor Help (this page)
The other options of the window are:
- The script editor text box: This is where you enter your script that will be used. If you use an external script file, this will display the content of the file (note however that modifying the script in this case does not modify the external file and changes are not saved).
- Script running from: Choose if the script should be run from the editor text box, or from an external script file.
- Script filename and path: Either the full path of the script, or click the Browse button to navigate to the file. This option is only available if you choose external script file in the Script running from option.
With the Run Script action, the On Error tab is accessible by right-clicking on the action in your process and clicking Advanced Properties.
The On Error tab will be triggered if your script has an execution error (such as syntax error, etc) as well as when raising an error from within your script.
On Error Tab
For a description of the options on the On Error tab see Using the On Error tab.
Miscellaneous Tab
The Miscellaneous tab is common to all tasks.
It contains a text area (Task comments) that lets you write comments about the task. These comments are saved when the dialog is closed with the OK button and are displayed in the Task Comments Pane.
Check the option Use as step description to display the text next to the icon of the plugin in the Process area.
The tab also provides an option to highlight the task in The Process area with the default color, set in the Preferences (see General appearance preferences), or the color selected or defined under Highlight color on this tab.
To revert the selected highlight color to the default color, open this tab, turn the Highlight option off and close the dialog with the OK button; then turn highlighting back on.
Highlighting can also be turned on and off via the task's contextual menu and with the Highlight button on the View ribbon.