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.
5:: GOTO 3
else:: Call Error('The CASE value must be 1, 3, or 5. A value of XXXF0 was provided.',V)
PROCEDURE MDAS(OP$,X,Y: R)
'Divide':: If (Y<>0) Then
Call Error('Attempt to divide by zero.')