Contents - Index
The $RunMacroBefore provides an easy way to embed macro commands within the Equations window, as an option to using the Macro window to play the macro commands. As implied in its name, the $RunMacroBefore directive will play the specified macro commands before after the equations have been compiled, but before the calculations have been initiated. There are a large number of macro commands that may be appropriate to use with this directive, e.g., to create or open a Lookup table, import data, or run programs that export data needed for the current program. The directive can be used with the Solve, MinMax and Uncertainty Propagation commands and their related commands that use the Parametric table.
There are two formats for the $RunMacroBefore directive. The first format requires the name on the tab of an existing macro file in the Macro Window or the complete name of an external macro file (having an .emf file name extension) to be provided directly following the $RunMacroBefore keyword, .e.g,
$RunMacroBefore 'Macro 1'
The second format provides the macro commands in the Equations window between the $RunMacroBefore directive and the required $EndMacro directive, as in Example 1.
Note that variables defined in the macro are also set in the main program and cannot be overwritten.
This example uses a $RunMacroBefore macro to create a Lookup table and fill it with data then create a Parametric table with columns Row, X, and Y, and then fill the Row column with values. All of this happens before the calculations are initiated with the Solve or Solve Table commands.
NewLookup L$ Rows=5 Cols=2
LookupColInfo L$ 1 'X'
LookupColInfo L$ 2 'Y'
LOOKUP[L$, Row1, 1]=Row1
LOOKUP[L$, Row1, 2]=Row1^2
NewTable 'Table 1' Rows=5 Row,X Y
AlterValues 'Table 1' Row Rows=1..N First=1 Last=N
This example creates a property plot for steam using the PropPlot macro command
$UnitSystem SI C kPa mass
PropPlot Steam Tv 4 10000 4000 1000 200 DEF DoQLines
See also: Macro Commands