Contents - Index


$IF and $IFNOT

 

The $IF and $IFNOT directives allow conditional exclusion of EES equations that are entered in the Equations window.  

 

The format of this directive is:

 

$IF Condition  

...

...

$ELSE

...

...

$ENDIF

 

 

These directives test the condition that follows the $IF/IFNOT keyword.  Condition can be a simple test (e.g., T$='C') or a boolean expression consisting of many tests combined with the OR and AND operators, e.g., ((T$='C) OR (T$='K')) AND (P$='kPa').  If the condition is true (for the $IF directive) or not true (for the $IFNOT directive), the equations that follow the $IF/IFNOT directive up to the $ELSE (if present) or the $ENDIF keyword are compiled and included with other equations in the EES Equations window.  If the condition is false, the equations are ignored.  Multiple $IF/IFNOT directives can be used and they may be nested. 

 

Recognized condition keywords are:

 

DIAGRAMWINDOW

This condition is true if the main Diagram Window is displayed on the screen.  In this case, any input variables that are defined in the Diagram Window will be used while compiling the equations.  If the Diagram Window is hidden (by selecting the close button at the upper right corner of the window), any input variables defined in the Diagram window are ignored and the DIAGRAMWINDOW condition is false.  

 

INTEGRALTABLE

This condition is true if a $INTEGRALTABLE directive appears in the EES file.  The $INTEGRALTABLE directive can appear above or below this conditional test as EES will initiate a 2-pass compilation if a test for the existence of an Integral Table is required.

 

MACRO

This condition is true if the calculations have been initiated by running or playing a Macro command list.

 

MIN/MAX  (or MINMAX)

This condition is true if calculations have been initiated with the Min/Max command.

 

MIN/MAXTABLE   (or MINMAXTABLE)

This condition is true if calculations have been initiated with the Min/Max Table command.

 

MIN/MAXTABLE   (or MINMAXTABLE)='Table Name'

The condition returns true if calculations are initiated with the Min/Max Table command  are applied to the Parametric Table named 'Table Name'.   The table name should be a string constant enclosed in single quotes.  String variable names are not accepted.

 

PARAMETRICTABLE

This condition returns true if calculations have been initiated with the Solve Table, Min/Max Table or Uncertainty Propagation Table commands.  It otherwise returns false. 

 

PARAMETRICTABLE='Table Name'

The condition returns true if calculations initiated with the Solve Table, Min/Max Table or Uncertainty Propagation Table commands are applied to the Parametric Table named 'Table Name'.   The table name should be a string constant enclosed in single quotes.  String variable names are not accepted.

 

TABLERUN# = Value   or   TABLERUN# < Value   or    TABLERUN# > Value

The condition returns true if calculations are initiated with the Solve Table, Min/Max Table or Uncertainty Propagation Table commands and the run (or row) in the Parametric Table that is currently being solved is equal to, less than, or greater than Value.  Value must be an integer number.  When this directive is used, EES must recompile the equations in the Equations window after every run in the Parametric Table until the condition is satisfied, so the calculation speed is reduced.  The display may flicker as the equations are compiled.  

 

UNITSYSTEM('XX')

'XX' can be any of the following unit specifications:  'SI', 'Eng', 'Mass', 'Molar', 'Deg', 'Rad', 'kPa', 'bar', 'psia', 'atm', 'C', 'K', 'F', 'R', 'Pa', 'MPa', and 'KJ'

The UNITSYSTEM condition returns true if the unit specification provided as the argument with the UNITSYSTEM condition is selected in the Unit System dialog.  

 

StringVariable$='String constant' 

StringVariable$ is any EES string variable that is defined before the $IF directive.  The string variable can be defined in the Equations window or in the Diagram window. The text to the right of the equal sign is a string constant.  Single quotes around the string constant are optional.  Upper and lower case letters are not distinguished when testing equivalence between a string variable and string constant.  A dropdown list of strings is the most convenient means of setting a string variable in the Diagram window.

 

UNCERTAINTY

This condition is true if calculations have been initiated with the Uncertainty Propagation command.

 

UNCERTAINTYTABLE

This condition is true if calculations have been initiated with the Uncertainty Propagation Table command.

 

UNCERTAINTYTABLE='Table Name'

The condition returns true if calculations are initiated with the Uncertainty Propagation Table command  are applied to the Parametric Table named 'Table Name'.   The table name should be a string constant enclosed in single quotes.  String variable names are not accepted.

 

 

A common use of this directive is to set variables that are used with the Solve command but not with the Solve Table command.

 

 

Examples:

 

$IFNOT  ParametricTable

   Row=1 {­This equation is used only if a Parametric Table is not used}

$endif

x=Row^2

 

$UnitSystem Eng F  {try changing to SI C}

T=200 [F]

$IF UNITSYSTEM('F')=1

TC=(T-32[F])/1.8  {­This equation converts the temperature from F to C}

$ELSE

TC=T

$ENDIF

 

X$='abc'

$IF X$='abc'

    y=3 {­This equation is executed only if X$='abc'}

$ELSE

    y=5

$ENDIF

 

$if Tablerun#<13 "change the guess value and upper limit for variable M as a function of run # in the Parametric table."

    M_guess=0.2

    M_max=0.9999

$elseif

M_guess=1.2

M_max=10

$endif

 

A$='A';  B$='D'

$if (A$='A') and ((B$='B') or (B$='C'))

z=1

$elseif

z=2

$endif

 

 

Directives