Case

Description: Selects one of a set of parameters for execution and returns its return value.
Returns: Numeric
Usage: Script only.
Function Groups: Logic Control
Related to: ?: (If Else) | Cond | Execute | IfElse | IfThen
Format: Case(Index, P0, P1, P2)
Parameters:  
Index
Required. Any numerical expression giving the parameter number to execute. If this value is 0, the parameter executed is P0.
P0, P1, P2, …
Required. The statements, one of which will be executed as specified by the value of Index.
At most one statement is executed. These parameters are typically Execute statements.
Comments: The return value of this function is the return value of the parameter executed, or invalid if no parameter is executed.

Example:

If 1 Main;
[
  Case(pumpNum { Number varies from 0 to 3 }, 
               { 0 }pumpDesc = "Pump 0", 
               { 1 }Execute(pumpDesc = "Pump 1", Diesel = TRUE),
               { 2 }pumpDesc = "Pump 2", 
               { 3 }pumpDesc = "Pump 3"); 
]

This sets the pumpDesc variable according to pumpNum and in the second case, uses the Execute function to accomplish more than one task based on the value of pumpNum. If setting pumpDesc was all that was needed to be done, the statement could have been shortened to:

If 1 Main;
[
  pumpDesc = Case(pumpNum, 
                 { 0 } "Pump 0", 
                 { 1 } "Pump 1", 
                 { 2 } "Pump 2", 
                 { 3 } "Pump 3"); 
]

Note that this example is written as English-only for clarity. For a multilingual application, each possible description should be phrase key.