Fourth World Logo Fourth World Media Corporation
  Embassy Services Products Resources   About Fourth World Contact  


IncWell Logo

SuperCard FAQ

4W Logo

How do I create a default expression for "switch" statements?


A switch statement can be used in one of two ways, either looking for a matching value, or a true evaluation of a Boolean expression.

In the former case, just make sure that the comparison value of the last case block is the value to which it will be compared. For example:

switch empName
case "Steve"
-- Do Steve stuff
exit switch
case "Bob"
-- Do Bob stuff
exit switch
case empName -- Exact match guaranteed
-- Do default stuff
end switch

In the latter case, all you need to do is make sure that the last case statement is something which will always evaluate to true, e.g.:

switch
case empName = "Steve"
-- Do Steve stuff
exit switch
case empName = "Bob"
-- Do Bob stuff
exit switch
case empName = empName -- Exact match guaranteed
-- Do default stuff
end switch