The switch statement is used to perform pattern matching on a specified string value. It is particularly useful in situations where you have many possible values for a string and where nested if/then/else statements would be cumbersome.
When a switch statement is executed, the value of the switch variable is compared with the match clause in each case statement. The match clause is in the format specified in response to line or char definitions. When ESL finds a match in one of the case statements, it then executes all the action statements listed below the case statement.
No matter how many case statements match the string, only the first is executed. If ESL finds no case statements that match the value of the switch variable, it will perform the action statements following the default statement. (All switch statements must have a default statement, which cannot be followed by any other case statements.)
In the following example, if the value of the variable Appl_Var is the string, "Please enter name:", the second case statement is executed.
switch (Appl_Var) is
case char "bad transmission" is
...
case char "enter name" is
...
case char "more data" is
...
default is
...
end switch