Stephen-

I have three rules of thumb for selecting switch/case constructs vs
if/then/else constructs (or at least three that I can think of off the
top of my head):

1. As Rob Cozens has pointed out, if I have more than two choices then
I will probably convert to a switch statement.

switch itemToTest
  case 2
  case 3
  case 4
    answer "it's a" && itemToTest
    break
  default
    answer "it's unknown"
end switch

2. If I have a few exceptions to a regular rule then I will make a
case statement with a break and put the rule in the default handler.

switch itemToTest
  case NOPPMTooHigh
  case HCLPPMTooHigh
    put "failed" into tSmogTestResult
    break
  default
    put "passed" into tSmogTestResult
end switch

3. If I have a list of targets that I will probably want to expand
then that's a candidate for a switch statement.

switch itemToTest
  case
    "sloth"
    "envy"
    "gluttony"
    put "sin" into whatIsIt
    break
  default
    put "virtue" into whatIsIt
end switch

-- 
-Mark Wieder
 [EMAIL PROTECTED]

_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to