Discuss Scratch

Think_Quest
New Scratcher
14 posts

Switch

I was thinking maybe we could have a switch block:
switch()
case()
do this
case()
do this
case()
do this
default
do this
it would look like an if/else block, but there's a little + in the bottom-left corner to add a case.
if <> then
else
end
Speaking of if/else, maybe we could have an if/else if/else
RPFluffy
Scratcher
1000+ posts

Switch

What? Could you make your SBs better, see this for help, but anyways I would like more explaination!
OmnipotentPotato
Scratcher
1000+ posts

Switch

No support.
stickfiregames
Scratcher
1000+ posts

Switch

Think_Quest wrote:

Speaking of if/else, maybe we could have an if/else if/else
has 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 cstart
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
so if you have this:
when green flag clicked
ask [What's your favorite color?] and wait
set [color v] to (answer)
Instead of doing this:
if <(color) = [green]> then
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
You can do this:
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)

TheHockeyist
Scratcher
1000+ posts

Switch

Actually, now that I think about it, support.
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

djdolphin wrote:

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

ShamelessSnores wrote:

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

Think_Quest wrote:

Here's a more clear version:
switch( v)::control cstart
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
so if you have this:
when green flag clicked
ask [What's your favorite color?] and wait
set [color v] to (answer)
Instead of doing this:
if <(color) = [green]> then
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
You can do this:
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

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

OmnipotentPotato wrote:

@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

RPFluffy wrote:

OmnipotentPotato wrote:

@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
Oh, xD
RPFluffy
Scratcher
1000+ posts

Switch

OmnipotentPotato wrote:

RPFluffy wrote:

OmnipotentPotato wrote:

@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
Oh, xD
xD, lol!

Powered by DjangoBB