Moving Statements in Scripts

One or more statements can be moved by highlighting them and pressing Ctrl+Shift+Up or Ctrl+Shift+Down, or by using the Move Up or Move Down buttons at the bottom of the Script dialog.

There are, however, several rules that determine when GoldSim will allow a given selection to be moved.  A statement that opens a scope, such as an IF statement or DO loop, cannot be moved to below the statement that closes the scope (e.g., the corresponding ELSE, ELSE IF, of End IF statement for an IF or the END DO for a DO loop).  Similarly, a statement that closes a scope cannot be moved up to above the statement that opens a scope.

For example, in the script shown below, the line 1 could not be moved below line 3 because doing so would move a scope-opening statement below the corresponding scope-closing statement.  Similarly, line 3 could not be moved above line 1.

A selection of an incomplete scope, such as one that includes a DO statement without the corresponding END DO statement, cannot be moved into a higher scope or a lower nested scope, as this would create an illogical script where the scope-opening statement becomes separated from its corresponding scope-closing statement.  For example, in the script shown below, line 2 cannot be moved up and line 4 cannot be moved down, but if you selected lines 2 through 4 at the same time, you would be able to move the entire Do loop statement block.

If you select an incomplete scope and attempt to move it up/down into another scope that is at the same level, the selection will be moved up/down past the other scope, which will have the result that the scopes will be nested.  As an example of this, consider the following script:

If you try to move line 4 up, it is moved all the way to the top, resulting in nested Do loops:

Related Topics…

Learn more about: