Contents - Index


$RunMacroBefore

 

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 of an existing macro file (having an .emf file name extension) to be provided directly following the $RunMacroBeforekeyword, .e.g,

 

$RunMacroBefore C:\Temp\MyMacro.emf

 

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.

 

Example 1: 

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.

 

$RunMacroBefore 

DeleteLookup 1

L$='Lookup 1'

NewLookup L$ Rows=5  Cols=2

LookupColInfo L$ 1  'X'  

LookupColInfo L$ 2  'Y'  

N=5

Row1=0

repeat

  Row1=Row1+1

  LOOKUP[L$, Row1, 1]=Row1

  LOOKUP[L$, Row1, 2]=Row1^2

until (Row1>=N)

DeleteParametric 1

NewTable 'Table 1'  Rows=5 Row,X Y

AlterValues 'Table 1' Row Rows=1..N First=1 Last=N

$endmacro

 

$ifnot ParametricTable 

  Row=3

$endIf

x=lookup(L$,Row,'x')

y=lookup(L$,Row,'y')

 

Example 2:

This example creates a property plot for steam using the PropPlot macro command

 

$UnitSystem SI C kPa mass

$RunMacroBefore

PropPlot Steam Trho 5 11000 5300 2100 660 299 6 0.075 1 3.5 12 50 150 DoQLines

$EndMacro

 

 

See also: Macro Commands

               Create Macro

               $RunMacroAfter

 

 

Directives