Stream Scripts

Scripts can be used to customize operations within a particular stream, and they are saved with that stream. Stream scripts can be used to specify a particular execution order for the terminal nodes within a stream. You use the stream script dialog box to edit the script that is saved with the current stream.

To access the stream script tab in the Stream Properties dialog box:

  1. From the Tools menu, choose:

    Stream Properties > Execution

  2. Click the Execution tab to work with scripts for the current stream.

Use the toolbar icons at the top of the stream script dialog box for the following operations:

  • Import the contents of a preexisting stand-alone script into the window.
  • Save a script as a text file.
  • Print a script.
  • Append default script.
  • Edit a script (undo, cut, copy, paste, and other common edit functions).
  • Execute the entire current script.
  • Execute selected lines from a script.
  • Stop a script during execution. (This icon is only enabled when a script is running.)
  • Check the syntax of the script and, if any errors are found, display them for review in the lower pane of the dialog box.
Note: From version 16.0 onwards, SPSS® Modeler uses the Python scripting language. All versions before 16.0 used a scripting language unique to SPSS Modeler, now referred to as Legacy scripting. Depending on the type of script you are working with, on the Execution tab select the Default (optional script) execution mode and then select either Python or Legacy.

You can specify whether a script is or is not run when the stream is executed. To run the script each time the stream is executed, respecting the execution order of the script, select Run this script. This setting provides automation at the stream level for quicker model building. However, the default setting is to ignore this script during stream execution. Even if you select the option Ignore this script, you can always run the script directly from this dialog box.

The script editor includes the following features that help with script authoring:

  • Syntax highlighting; keywords, literal values (such as strings and numbers), and comments are highlighted.
  • Line numbering.
  • Block matching; when the cursor is placed by the start of a program block, the corresponding end block is also highlighted.
  • Suggested auto-completion.

The colors and text styles that are used by the syntax highlighter can be customized by using the IBM® SPSS Modeler display preferences. To access the display preferences, choose Tools > Options > User Options and select the Syntax tab.

A list of suggested syntax completions can be accessed by selecting Auto-Suggest from the context menu, or pressing Ctrl + Space. Use the cursor keys to move up and down the list, then press Enter to insert the selected text. To exit from auto-suggest mode without modifying the existing text, press Esc.

The Debug tab displays debugging messages and can be used to evaluate script state once the script is executed. The Debug tab consists of a read-only text area and a single-line input text field. The text area displays text that is sent to either standard output or standard error by the scripts, for example through error message text. The input text field takes input from the user. This input is then evaluated within the context of the script that was most recently executed within the dialog (known as the scripting context). The text area contains the command and resulting output so that the user can see a trace of commands. The text input field always contains the command prompt (--> for Legacy scripting).

A new scripting context is created in the following circumstances:

  • A script is executed by using either Run this script or Run selected lines.
  • The scripting language is changed.

If a new scripting context is created, the text area is cleared.

Note: Executing a stream outside of the script pane does not modify the script context of the script pane. The values of any variables that are created as part of that execution are not visible within the script dialog box.