Contents - Index


IF THEN ELSE (Macro Command)

 

The IF THEN ELSE command in a macro file can test variables that have been defined within the macro or in the previous execution of the Solve or Solve Table command.  The tests following the IF keyword can use any of the following logic operators: <, <=,  =,  <>,  >, >=  .  The IF test can use one or more AND and OR operators.  The AND and OR must be surrounded by one or more spaces.  The order of the logical operations can be controlled by parentheses.   The tested variables may be numerical variables or string variables.  When comparing numerical values, the use of the equal (=) operator should be avoided as EES does not use integers and real variables may not be exactly the value you are testing against.  Only the = and the <> logic operators are applicable when testing string variables or string constants.  Both single-line and multiple-line formats are provided for IF THEN ELSE statements in a Macro. 

 

Single-Line Format

The entire command must be all on one line as in the following example.  The THEN keword is required.  The ELSE keyword and following clause are optional. An ENDIF keyword must not appear.  The IF command will usually be used with the GOTO command and line labels.  

 

    IF (X<=Y) OR (S='ABC') THEN Z=3 ELSE Z=4

 

Multiple-Line Format (EES version 12.132 or newer)

Multiple-line IF statements allow a group of one or more statements to be executed depending on the result of the comparison test.

An example of a multiple-line IF THEN ELSE construct is:

 

IF (X<=Y) OR (S$='ABC')  THEN

   ...

   ...

ELSE

  ...

  ...

ENDIF

 

The Iine with the IF statement must end with the THEN keyword.  One or more Macro commands follow on separate lines up to the ELSE or ENDIF keyword.  The ELSE keyword and Macro commands that follow are optional.  An ENDIF keyword must be provided as a terminator.  Nested multiple-line IF THEN ELSE commands are not allowed.

     

See also: GoTo statement

               Repeat Until

 

MacroCommands