Switch,Case Structure
David Vaughan
drvaughan55 at mac.com
Fri May 17 19:33:01 EDT 2002
Barry
There is nothing apparently wrong with your code so forget the
formatting so long as it works. Parentheses around the switched variable
are entirely a matter of taste :-). Since you are just now trying
switch, this demonstrates essentially all its behaviour variations:
-- Demonstrate switch statement (formatting by courtesy of Rev)
on mouseUp
ask "what value?"
switch it
case 1
answer 1
break
case 2
answer 2
case 3
answer 3
default
answer "default"
end switch
end mouseUp
Run it four times,successively entering 4, 3, 2, 1 and note the effects
of "break", "default" and the sequence.
regards
David
On Saturday, May 18, 2002, at 02:57 , Barry Levine wrote:
> I'm trying to understand the "Switch/Case" structure and having a hard
> time.
>
> Let's say I've got a value in myVar that could be anything from 1 to 3.
> I want to call a handler specific to that value and not any other
> handler after that. Let's say "doOne", "doTwo", "doThree". According to
> how I understand the Rev docs on this subject, I would create this:
>
> switch (myVar)
> case 1
> doOne
> break
> case 2
> doTwo
> break
> case 3
> doThree
> break
> end switch
>
> When I do this in my handler, the switch and case lines are aligned
> rather than indented so I've probably pooched something. Any ideas?
>
> Thanks,
> Barry
> --------------------------------------------------------
> Barry Jay Levine
> "The Mac Guy"
> Macintosh Troubleshooting, System Engineering, Training,
> AppleShare/OSX Server Setup, System Upgrades and Enhancements
> On-Site service for K20, Business, Consumer
> Phone/VoiceMail: 915-581-1105
> Fax: 915-581-8167
> eMail: themacguy at mac.com
> --------------------------------------------------------
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list