Discuss Scratch
- Discussion Forums
- » Suggestions
- » Switch
- Think_Quest
-
New Scratcher
14 posts
Switch
I was thinking maybe we could have a switch block:
switch()it would look like an if/else block, but there's a little + in the bottom-left corner to add a case.
case()
do this
case()
do this
case()
do this
default
do this
if <> thenSpeaking of if/else, maybe we could have an if/else if/else
else
end
- stickfiregames
-
Scratcher
1000+ posts
Switch
Speaking of if/else, maybe we could have an if/else if/elsehas been suggested here.
- TheHockeyist
-
Scratcher
1000+ posts
Switch
*confused* No support even if it was explained to me clearly.
Last edited by TheHockeyist (Nov. 11, 2014 18:14:40)
- Think_Quest
-
New Scratcher
14 posts
Switch
Here's a more clear version:
switch( v)::control cstartso if you have this:
case[]::control cstart
do this
end
case[]::control cstart
do this
end
case[]::control cstart
do this
end
default::control cstart
do this
end
end
when green flag clickedInstead of doing this:
ask [What's your favorite color?] and wait
set [color v] to (answer)
if <(color) = [green]> thenYou can do this:
say [I like green too.] for (2) secs
else
if <(color) = [red]> then
say [Red is pretty good.] for (2) secs
else
if <(color) = [blue]> then
say [Blue is cool.] for (2) secs
else
say [I don't know that color.] for (2) secs
end
end
switch[X v]::control cstart
case[green]::control cstart
say [I like green too.] for (2) secs
end
case[red]::control cstart
say [Red is pretty good.] for (2) secs
end
case[blue]::control cstart
say [Blue is cool.] for (2) secs
end
default::control cstart
say [I don't know that color.] for (2) secs
end
end
Last edited by Think_Quest (Nov. 11, 2014 21:38:42)
- djdolphin
-
Scratcher
1000+ posts
Switch
The wording of “switch” and “case” would be way to confusing to people new to programming.
- TheHockeyist
-
Scratcher
1000+ posts
Switch
The wording of “switch” and “case” would be way to confusing to people new to programming.Yeah. We need better terminology.
- ShamelessSnores
-
Scratcher
100+ posts
Switch
No support… Easy to use workarounds, this will make it harder…
- TheHockeyist
-
Scratcher
1000+ posts
Switch
No support… Easy to use workarounds, this will make it harder…Switching my stance to no support as per this.
- RPFluffy
-
Scratcher
1000+ posts
Switch
Here's a more clear version:switch( v)::control cstartso if you have this:
case[]::control cstart
do this
end
case[]::control cstart
do this
end
case[]::control cstart
do this
end
default::control cstart
do this
end
endwhen green flag clickedInstead of doing this:
ask [What's your favorite color?] and wait
set [color v] to (answer)if <(color) = [green]> thenYou can do this:
say [I like green too.] for (2) secs
else
if <(color) = [red]> then
say [Red is pretty good.] for (2) secs
else
if <(color) = [blue]> then
say [Blue is cool.] for (2) secs
else
say [I don't know that color.] for (2) secs
end
endswitch[X v]::control cstart
case[green]::control cstart
say [I like green too.] for (2) secs
end
case[red]::control cstart
say [Red is pretty good.] for (2) secs
end
case[blue]::control cstart
say [Blue is cool.] for (2) secs
end
default::control cstart
say [I don't know that color.] for (2) secs
end
end
Sorry but here is a workaround:
when green flag clicked
ask [What is your favorite color?] and wait
set [color v] to (answer)
when green flag clicked
forever
if <(answer) = [Blue ]> then
//And so on!
end
end
And the if/else in an if/else would be this:
if <> then
else
if <> then
else
end
end
Unless you mean this.
So no support!
Last edited by RPFluffy (Nov. 12, 2014 01:19:14)
- OmnipotentPotato
-
Scratcher
1000+ posts
Switch
@RP-Fluffy the OP literally said the workaround that you mentioned is not the same.
- RPFluffy
-
Scratcher
1000+ posts
Switch
@RP-Fluffy the OP literally said the workaround that you mentioned is not the same.What? I meant like this:
when green flag clicked
forever
if <[] = [ ]> then
end
if <[] = [ ]> then
end
if <[] = [ ]> then
end
end
- OmnipotentPotato
-
Scratcher
1000+ posts
Switch
Oh, xD@RP-Fluffy the OP literally said the workaround that you mentioned is not the same.What? I meant like this:when green flag clicked
forever
if <[] = [ ]> then
end
if <[] = [ ]> then
end
if <[] = [ ]> then
end
end
- RPFluffy
-
Scratcher
1000+ posts
Switch
xD, lol!Oh, xD@RP-Fluffy the OP literally said the workaround that you mentioned is not the same.What? I meant like this:when green flag clicked
forever
if <[] = [ ]> then
end
if <[] = [ ]> then
end
if <[] = [ ]> then
end
end
- Discussion Forums
- » Suggestions
-
» Switch






