Page 1 of 1

Switch Statement - multiple selection

Posted: Wed Mar 02, 2011 9:03 am
by stevewhyte
Hi,

Me again. Sorry!

I'm trying to make use of a switch statement for multiple selection. Depending upon what the user enters, will depend on what message will be displayed. Here is what I have so far:

-----------

global choice

on mouseUp
ask "Please enter your colour"
put it into choice

switch
case choice "Red"
case choice = "Blood is red" into line 1 of field "output"

case choice "Blue"
case choice = "The sea is blue" into line 1 of field "output"

case choice "Black"
case choice = "Coal is black" into line 1 of field "output"

case choice "Green"
case choice = "Grass is green" into line 1 of field "output"

case choice "Yellow"
case choice = "The sun is yellow" into line 1 of field "output"

else

put "Sorry, there is no message for that colour." into line 1 of field "output"

end switch

end mouseUp
--------------------


It doesn't work because my structure is all wrong and I don't think a switch statement can contain an else.

Can anyone advise? Also, is it possible to also change the card colour so when the user enters a colour, the message is displayed and the card background changes colour at the same time?

Very kindest regards,

Steven :D

Re: Switch Statement - multiple selection

Posted: Wed Mar 02, 2011 10:52 am
by Dixie
Steven...

Yes, you have your 'switch' statements a little mixed up. I have attached a stack that should help you with your 'switch' statements and show you how to change the colour of the card as you want to do...

be well

Dixie

Re: Switch Statement - multiple selection

Posted: Wed Mar 02, 2011 11:50 am
by stevewhyte
Dixie,

Thank you so much for this. You have been most helpful!!

:mrgreen: