Scripting

Scripting is a often a necessary component of any simulation. The scripting allows the simulation to manage behaviour outside the default scope and control some parameters of the equipment and controls.

 

The Scripting language supported is only JavaScript (V8 version).

 

There are two ways to access the Scripting window;

 

The Scripting Window

The Scripting window is divided into a menu and four areas;

Left panel: The left panel is a tree of the script areas that are available and any script sections added.

Simulation Scripts: Execute all scripts when the simulation starts

 

All Scripts are saved with the Project.

A new script can be created by using Right click and selecting New.

When the simulation starts, then all scripts in that section are appended to the Main script and executed as one. This allows scripts to be broken down into logical subsets to aid in portability.

 

Execution in a subscript is by calling the function from the Main script. e.g. InitHeartbeat();

 

Middle panel: This is the main panel which contains the text of the current script in edit mode.

 

Status bar: The status bar appears between the Main script panel and the bottom message panel. It shows;

List: A drop-down list of all the functions defined in the current script. Selecting one of these positions the main panel at the function definition.

Ln1: Current Line number

Col1: Current Column number

INS/OVR: State of the Insert key. INS means the keyboard is in Insert mode, OVR means the keyboard is in Overwrite mode.

 

Error panel: This panel displays any output messages from the script editor. These may indicate and errors in the structure of the script. e.g. missing brackets etc

 

Script menu

File:

New: Open a new empty Script window. Default name 'SimulationScript1'.

Import: Load an existing script into a new window using the name provided

Exit: Close the Scripting window without removing the scripts

Save: Save the current project (including the scripts)

 

Edit:

Undo: Undo the last action

Redo: Redo the last undo

Cut: Cut the selected text

Copy: Copy the selected text

Paste: Paste the selected text

Delete Line: Delete the line the cursor is on

Comment Selection: Insert comment characters ('//') in front of each selected line

Uncomment Selection: Remove comment characters ('//') from the front of each line

Select All: Select all of the script text in this window

 

Search:

Find: Open the 'Find and Replace' dialogue box with the 'Find' tab selected.

Replace: Open the 'Find and Replace' dialogue box with the 'Replace' tab selected.

Incremental Search: Open the Search dialogue box to search and highlight the matching text

Goto Line: Open the 'Go To Line' dialogue box to specify a line to position at.

 

View:

Show/Hide Errors: Hide or Show the error box at the bottm of the Script window

Show Line Numbers: Hide or Show Script line numbers

Highlight Current Line: Disable or enable a highlight of the current line

Show Indentation Guides: Hide or Show the indentation Guides

Enable Folding: Disable or Enable Folding

Zoom In: Make the text larger for the visually challenged

Zoom Out: Make the text smaller for the showoffs