Tour Page 16

|

Using Scripts for Complex Calculations

GoldSim Quick Tour (16 of 23)

In some situations, you may wish to define a complex function which cannot be readily implemented using the expression editing features supplied by GoldSim. For example, calculation of an output may require very complex logic which would be cumbersome to represent using standard GoldSim elements, or it may require a numerical solution technique (e.g., iteration); or perhaps you need to construct an array using complex logic.

Although, for some complex calculations, an External (DLL) element may be required, for many applications a Script element can be used. The key advantages of a Script over an External (DLL) is that 1) it does not require use of a separate programming language and interface; and 2) it is much more transparent (all of the “code” can be seen directly in GoldSim):

Looping Container

Scripts are created by inserting and editing statements or statement blocks, which may be variable definition statements, variable assignment statements, statements controlling the sequence of execution in the script (e.g., loops and if statements), or statements used for writing messages to a log file. Script elements even have their own built-in debugging features (e.g., breakpoints).

The Script element does not expect the user to learn or be familiar with a particular language. As a result, 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.

   

 

Making Better Decisions In An Uncertain World