Interactive Scripting

How to update and test script code interactively, without solving the model.

You can create script prototypes for pre- and post-processing of a model. The IDE contains a testing area in which you can write script code and run it to see the results immediately. It is not necessary to wait for a model to solve after each modification of script.

Before experimenting with your script code, you need to execute the run configuration at least once, to be able to access data initialized in the .dat file, or decision variables (dvar) that are populated when the solve is done.

In the following example we use the cutstock model (cutstock.mod). The screen capture shows the IDE after the initial run, with the testing area Interactive scripting available in the Scripting log tab.

Empty Interactive scripting area in Scripting log.

If the Interactive scripting area is not displayed, click the > > arrows in the Scripting log.

Show Interactive scripting tooltip

Click the << arrows to hide Interactive scripting.

Hide Interactive scripting tooltip

Executing script code in the testing area

In the Interactive scripting area, enter the script you would like to test before adding it to your model. Right-click inside Interactive scripting and select an Execute command.

Execute commands in Interactive scripting

The Execute commands are also available in the toolbar at the top right of the Scripting log tab.

Execute buttons in the Scripting log

The result of the execution is displayed in the Scripting log.

Results from Interactive scripting displayed in the scripting log.

When you are satisfied with the result of your script, you can drag, or copy and paste, the code from the Interactive scripting area into the model.

Dropping script code into the Scripting log

You can drop script code into the Scripting log from:

  • the Interactive scripting area

  • the IDE editor (.mod file)

  • an external editor

and it will be executed in the Scripting log.

Executing script code in the editor

You can also modify the script code directly in the editor, then select it to test it with the command Execute selection. The result is displayed in the Scripting log.

Execute selection command in editor for interactive scripting

Removing code

  • To remove code from the Interactive scripting area, right-click inside the area and select Clear Interactive scripting.

    Clear Interactive scripting command
  • To remove code from the Scripting log, click the ‘clear’ button in the toolbar at the top right of the Scripting log tab.

    ‘Clear Scripting log’ button