Switch Constructs

The switch construct is an alternative to branching into several different blocks of code:

 

Switch Parameter1

Case 10

   DoAny := 10

Case 20

   DoAny := 11

Case Else

   DoAny := 100

End Switch

The DoAny variable is given a value of 10 if parameter1 is 10, and is given a value of 11 if parameter1 is 20. Otherwise, DoAny gets the value 100.

 

 

Switch Parameter1

Case 10, 20, 30

   DoAny := 10

Case 40

   DoAny := 11

Case Else

   DoAny := 100

End Switch

The DoAny variable is given a value of 10 if parameter1 is 10, 20, or 30, and is 11 if parameter1 is 40. Otherwise, DoAny gets the value 100

 

 

Switch Parameter1

Case >= 10, <= 20

   DoAny := 10

Case In {80, 90}

   DoAny := 11

Case Else

   DoAny := 100

End Switch

The DoAny variable gets a value of 10 if parameter1 has a value between 10 and 20 and has got a value of 11 if parameter1 is between 80 and 90. Otherwise, DoAny gets the value 100.

 

 

A switch construct can also be left prematurely using the Exit Switch command

Switch Parameter1

Case >= 10, <= 20

   DoAny := A * 10 -30

   Exit Switch If DoAny < 0

   DoAny += 100

Case In {80, 90}

   DoAny := 11

Case Else

   DoAny := 100

End Switch