Scripts are created by inserting and editing individual statements (e.g., variable definition statements, variable assignment statements) or statement blocks (e.g., loops, if statements). The Script element sequentially evaluates the specified sequence of locally defined statements to determine its output(s).
It is important to understand that scripts are not created using a text editor. Rather, statements are inserted and edited within a “controlled environment” within the element’s property dialog in which the user selects from a number of available statement types. The syntax is already defined for each type of statement – the user simply specifies the attributes and properties for each statement via a dialog box when the statement is inserted. Statements can subsequently be moved, deleted, and edited.
There are three ways to insert a statement into a script:
1. Select an existing statement in the script. Press the Insert button at the bottom of the Script element dialog. When you press this button, the following choices appear:
Left-click on one of the statement types. It will be inserted below the selected statement.
2. Select an existing statement in the script. Press the appropriate hot-key for the statement type (indicated in the dialog above). It will be inserted below the selected statement.
Right-click in the statement number. This will bring up a context menu, whose first item is Insert. This expands to display all of the statement types shown above. Left-click on one of the statement types. It will be inserted below the selected statement.
Note: If you hold the Shift key while carrying out any of these three methods for inserting a statement, the statement will be inserted above the selected statement.
Note: When inserting statement blocks (e.g., If-Else statement, For loops), you can select multiple statements in an existing script (by left-clicking and dragging the line numbers), and GoldSim will “wrap” the statement block around the selected statements. Note, however, that this requires that the selection is a logically complete block of code (e.g., you could not select a portion of another loop).
Learn more about: