Switch statements within Switch statements

Charles Szasz cszasz at mac.com
Thu Jul 10 12:41:41 EDT 2008


Kay,

Thanks very much for your suggestions! I appreciate you taking time to
answer my question.



Kay C Lan wrote:
> 
> on menuPick pChosen
>   switch pChosen
>     case "1 Choice"
>        --avoid statements here to keep switch statement compact
>       handler1Choice
>     break
>      case "2 Choice"
>        handler2Choice
>     break
>     ...
>     ...
>      case "987 Choice"
>        handler987Choice
>      break
>     --always good to include in the development phase to hi-light
> omissions.
>     default
>       answer "A case I've not accounted for." titled "Case Omission"
>       --check the variable watcher - pChosen
>       breakpoint
>   end switch
> end menuPick
> 
> --the following will also be in the button script
> 
> on handler1Choice
>   switch the label of btn "Master"
>     case "Choice 1"
>        --statements here
>        --use a handler if too many statements
>      break
>     case "Choice 2"
>         --statements or handler
>      break
>      ...
>      ...
>     case "Choice 99"
>        --statements or handler
>     break
>     --always good to include in the development phase to hi-light
> omissions.
>     default
>       answer "A case I've not accounted for." titled "Case Omission"
>       --check the label of btn 'Master'
>       breakpoint
>   end switch
> end handler1Choice
> 
> on handler2Choice
>   --switch structure again
> end handler2Choice
> 
> as many as required.
> 
> Although nested switch statements are possible, and are easy enough to
> follow if you only have a small matrix of options to cover, once the
> options
> start to multiply it's very easy to created a very complex structure that
> is
> hard to follow and easy to miss options - which is why I like to use the
> default statement to catch omissions.
> 
> HTH
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 
> 

-- 
View this message in context: http://www.nabble.com/Switch-statements-within-Switch-statements-tp18374624p18385818.html
Sent from the Revolution - User mailing list archive at Nabble.com.




More information about the use-livecode mailing list