Creating Scripts

You use the Script Adapter to create scripts that operate on the parameters in your simulation process.

  1. From the Utilities section of the action bar, click Script and drop it on the process diagram.
  2. Double-click Script .
    The Script Editor appears.
  3. From the Language list, select the desired scripting language (Jython or DynamicJava).
  4. Optional: Clear the Auto-Parse option to highlight parameters.
    This option automatically highlights parameters in scripts. In long scripts, the highlighting can affect performance. You can clear the selection to turn off automatic highlighting.
  5. Type your script in the upper portion of the editor.

    The editor provides full undo/redo capability as well as cut/copy/paste functionality. You can right-click the text in the editor to access the functionality or use standard shortcuts, such as Ctrl-C and Ctrl-V.

  6. Click to create a parameter.

    The Create New Parameter dialog box appears, and you define attributes of the parameter, such as its name and type.

  7. Click Filters to filter the parameters by Name and Mode.
  8. To include a parameter in your script, do one of the following:
    • Select the parameter from the Parameter list, and click .

    • Type the name of the parameter directly in the script. The editor recognizes existing parameters and colors them blue. If you type a parameter name in your script that does not match an existing parameter, the Script Editor assumes that it is a script variable, and it will not be initialized to anything or stored.

    You cannot edit a parameter name once it has been recognized; you must delete the parameter reference and insert another one.

    You do not have to define a script variable before you use it provided that the first reference is an assignment. The adapter provides predefined variables that you can use in your script, such as the directory in which the adapter is executing.

  9. Optional: Use the Name and Mode filters to narrow the amount of parameters displayed.
  10. If necessary, alter the Script Type setting in the Parameter list using the menu that appears when you click the corresponding column.

    The available types are described in About Parameters Within Scripts.

  11. Click Ok to save your changes and to close the Script Editor.