A formula can include references to other data, so that the value of a field becomes dependent on that data. When this data is in the same model, the reference is known as an
internal reference. STEM can also retrieve data from other models and spreadsheets – see 4.13 External references, and also 6. Exchanging data.
For example, you might want to define the Maintenance Cost of a Resource to be 10% of its Capital Cost:
- Select Costs from the Resource icon menu. The Costs dialog appears.
- Select the Capital Cost field and enter the appropriate figure.
- Select the Maintenance Cost field and type the first part of the formula: “
0.1 * …
”.
- In order to refer to the Capital Cost, you need to add a string of text, the internal reference, which uniquely identifies the Capital Cost field for this Resource.
Either:
- click in the cell in the dialog grid where the Capital Cost value is displayed – notice that the mouse cursor changes to a over these cells, indicating that you can pick up reference text – or
-
press <F2> to return the focus to the dialog grid, then use the cursor keys to move up back to the Capital Cost field.
The string Capital is appended, so that the formula becomes 0.1 * Capital.
-
Press <Enter> or click the button to finish the edit. The completed formula is re-displayed in the formula bar, and the corresponding value is calculated and displayed in red in the dialog grid.
- Now if you subsequently modify the Capital Cost, you will see that the Maintenance Cost is automatically re-calculated to show 10% of the new value.
While you are editing a formula, you can open other dialogs in order to pick up references, either by clicking with the mouse, or using the keyboard. If you activate another dialog, or press <F2> to move to another field in the original dialog, the Editor is said to be in Reference Mode.
Note: Clicking on a dialog button in Edit or Reference Mode normally picks up reference text for that button. Hold down the <Shift> key if you want to actually push the button and access references for the inner fields.
As you move around in Reference Mode, the text for the current reference is updated in the formula bar, replacing the previous reference. Press <F2> again to return to the formula bar, retaining the reference text; or press <Esc> to return to the formula bar, discarding the latest reference.
You can continue to type numbers and operators and so on, while moving around the grid, and then the next move will insert a new string of reference text. Press <Enter> to commit the edit from any position. For a detailed table of mouse and keyboard actions in Reference Mode, see 4.6.7 Keyboard and mouse interface for data dialogs.
Note: Pressing <Enter> in Edit or Reference Mode usually finishes the edit, but you can press <Shift+Enter> if you want to actually push the button, in order to access references for the inner fields.