Building Custom Elements Using Scripts

Lesson 5, page 8 of 15

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 GoldSim's built-in elements The basic building blocks with which a GoldSim model is constructed. Each element represents a feature, pararamer, process or event in the model., or it may require a numerical solution technique (e.g., iteration); or perhaps you need to construct an array using complex logic.

To deal with such situations, you can specify a sequence of statements directly within the GoldSim interface using a Script An element that can be used to create a list of executable statements (e.g., variable definitions, variable assignments and statements controlling the sequence of execution such as loops and if statements) in order to implement complex logic and operations. element; in effect, building a custom element:

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 the Run Log.The Script element sequentially evaluates the specified sequence of locally defined statements to determine its output(s).

Note: 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.