switch

Purpose The switch statement is used to compare an item against multiple criteria and to perform a set of statements based on the result of the comparisons. Statements are executed in every comparison section in which the comparison yields true. Please note that the switch statement can have zero or more comparison sections; however there must only be zero or one default section. The switch statement differs from the if statement in that the if statement only executes one set of consequential statements after the comparison rather than the multiple consequential execution of the switch statement. Also please note that the fact that you specify the datatype to be used in the comparisons for each comparison section means that you can do multiple datatype comparisons in the Superx++ switch statement based on the same item.
Format switch({item to be compared}) {
   ({comparison datatype}) {comparison operator} {comparison value} {
      {execution statements}
   }
   .
   .
   .

   default {
      {execution statements}
   }
};

{item to be compared} an expression that evaluates to a stand alone variable, array or attribute or an object or member variable or array element or an attribute on an object.
{comparison operator} the operator to be used in the comparison for the comparison section
{comparison datatype} the datatype to be used in the comparison for the comparison section
{comparison value} the value (or an expression yielding a value) to be used in the comparison for the comparison section
{execution statements} the statements to be executed if the comparison yielded true in the comparison clause-- the statements in the default clause will only be executed if none of the comparison clauses evaluated to true
Example #1 switch(MyEmployee.EmployeeID) {
   (int) = 12345 {
      xout("You must be Joe Schmo");
   }
   (int) = 98765 {
      xout("You must be John Q");
   }
   default {
      xout("I have no idea who you are");
   }
};

If the EmployeeID member of the MyEmployee object yields 12345 then the first comparison clause evaluates to true and the string You must be Joe Schmo is sent to the output stream. If the EmployeeID member of the MyEmployee object yields 98765 then the second comparison clause yields true and the string You must be John Q is sent to the output stream. Lastly, if the EmployeeID member of the MyEmployee object yields neither 12345 nor 98765 then neither of the comparison clauses yield true and so the default clause executes, writing the string I have no idea who you are to the output stream.

Example #2 switch(MyPal.Age) {
   (int) = 18 {
      xout("\r\nAdult");
   }
   (int) = 35 {
      xout("\r\nEligible to run for president");
   }
   (int) = 65 {
      xout("\r\nSenior Citizen");
   }
   default {
      xout("Sorry, you're not old enough yet");
   }
};

If the Age member of the MyPal object yields 20 then the first <case> clause evaluates to true and the string Adult is sent to the output stream on a new line. If the Age member of the MyPal object yields 37 then the second <case> clause yields true and the string Eligible to run for president is sent to the output stream on a new line. If the Age member of the MyPal object yields 69 then the second <case> clause yields true and the string Senior Citizen is sent to the output stream on a new line. Lastly, if the Age member of the MyPal object yields any number less than 18 then none of the <case> clauses yield true and so the default clause executes, writing the string Sorry, you're not old enough yet to the output stream. The net effect is that for someone aged 69, the following lines would be written to the output stream:
Adult
Eligible to run for president
Senior Citizen