Contents - Index



CASE statements provide logical operations and they are similar to IF-THEN-ELSE statements in this respect.  Like IF-THEN-ELSE and REPEAT-UNTIL statements, CASE statements can only be used in EES Functions or Procedures.  CASE statements somewhat more convenient to use when the logic control must select from multiple options.


The CASE statement must be followed on the same line with the CASE decision variable, which may be an EES numerical (e.g., X) or string variable (e.g., X$).  The CASE options are identified with CASE labels followed by a double colon (::).  If the CASE decision variable is an EES numerical variable, the CASE labels must be integers.  If the CASE decision variable is a string variable, the Case labels must be string constants surrounded by single quotes.  An equation is normally placed on the same line after the CASE label.  Additional equations may follow and these equations will be executed if the Case variable matches the CASE label.  An ELSE label may optionally be used (without quotes) with either the numerical or string versions.  Control will transfer to the first equation after the ELSE keyword if the CASE variable does not match any of the CASE labels.  An ENDCASE keyword is used to finalize the CASE statement.


CASE statements may not be used in a nested manner.  Simple examples of the CASE statement follow to illustrate the syntax.



Function TESTCASE(V)

   Case V

      1:: X=V+41



      3:: testcase=V^2

      5:: Goto 3

   else:: Call error('The CASE value must be 1, 3, or 5.  A value of XXXF0 was provided.',V)



   3:  testcase=3







Procedure mdas(OP$,X,Y: R)

   Case OP$

        'Multiply'::  R=X*Y

        'Divide'::     If (Y<>0) Then 



                            Call error('Attempt to divide by zero.')


        'Add'::         R=X+Y

        'Subtract'::  R=X-Y

        ELSE::       R=0




Call mdas('Divide',3,4:R)



See Also:



    EES Functions 

    EES Procedures