Discuss Scratch
- Discussion Forums
- » Suggestions
- » Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
- thebriculator
-
100+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
Some scenarios using label blocks can't be worked around with loops. You can have as many unique labels as you want, but you can only have one
label [hello world v] :: controlblock and one
goto [hello world v] :: controlthen you have to use a different ones like
label [play game v] :: controland
goto [play game v] :: control
- Scratcher1002
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
OK, almost, you can have more than one goto block, BUT you can only have one label like this: Hello world Some scenarios using label blocks can't be worked around with loops. You can have as many unique labels as you want, but you can only have onelabel [hello world v] :: controlblock and onegoto [hello world v] :: controlthen you have to use a different ones likelabel [play game v] :: controlandgoto [play game v] :: control
Then you have to do something like: helloworld
I was thinking for the label thing, it would be like the broadcast stuff.
- scratchinghead
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
Support both.
- Econinja
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
That's not how we do that in Scratch. Most people (like me Multiple labels in a row? Simple, if there is no stop this script or goto label block, it keeps going. Like I said in my post:in Batch script, if you DON'T put a goto label code, it will go on and on until the end of the program or a goto label block is put on DESPITE other label blocks.[
And yes, I know that they are both workaroundable. I understand it might be confusing for newer Scratchers.. But, that's what the tutorials are for, same with the Help With Scripts section of the forum.

No support, if it's workaroundable, it's to make things much less confusing. And by the way your describing goto, you could do it with broadcasts:
broadcast [label v]Switch seems very confusing, and you are mixing up forums. The Help With Scripts forums is not for block help, it's for script help. There's a difference (block is only a particular block, script help is for scripts). The only thing you could use would be the help, but nobody goes there. People can also use the wiki.
when I receive [label v]
whatever :: custom-arg
//and if you want it looped
when I receive [label v]
whatever :: custom-arg
broadcast [label v]
- Scratcher1002
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
That's not how we do that in Scratch. Most people (like me Multiple labels in a row? Simple, if there is no stop this script or goto label block, it keeps going. Like I said in my post:in Batch script, if you DON'T put a goto label code, it will go on and on until the end of the program or a goto label block is put on DESPITE other label blocks.[
And yes, I know that they are both workaroundable. I understand it might be confusing for newer Scratchers.. But, that's what the tutorials are for, same with the Help With Scripts section of the forum.) leave the caps off in case we want to put more scripts in.
No support, if it's workaroundable, it's to make things much less confusing. And by the way your describing goto, you could do it with broadcasts:broadcast [label v]Switch seems very confusing, and you are mixing up forums. The Help With Scripts forums is not for block help, it's for script help. There's a difference (block is only a particular block, script help is for scripts). The only thing you could use would be the help, but nobody goes there. People can also use the wiki.
when I receive [label v]
whatever :: custom-arg
//and if you want it looped
when I receive [label v]
whatever :: custom-arg
broadcast [label v]
Guys, I KNOW it's workaroundable, and it might confuse new scratchers. I get what you are saying about the Help With Scripts forum, and I know it's workaroundable, but it would make scripts look nicer and cleaner.
- IronBit_Studios
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
No support due to the easy workarounds.
- Cream_E_Cookie
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
support
- Gaza101
-
500+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
The goto function encourages messy coding. Adding a quick goto block instead of restructuring your code demonstrates lazy programming and makes it harder for others to interpret your code. And why is the goto block messy?
If you have many different outcomes and need to reuse code, use nested ifs and definitions. Ever been in a situation where there is 100 different possible outcomes? Or when you don't want to repeat a block string again.. And again, and again… etc.
- Scratcher1002
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
I can understand why it maybe would encourage lazy coding.The goto function encourages messy coding. Adding a quick goto block instead of restructuring your code demonstrates lazy programming and makes it harder for others to interpret your code. And why is the goto block messy?If you have many different outcomes and need to reuse code, use nested ifs and definitions. Ever been in a situation where there is 100 different possible outcomes? Or when you don't want to repeat a block string again.. And again, and again… etc.
Um… Then you got this:
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
do something :: custom
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end

- Gaza101
-
500+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
I can understand why it maybe would encourage lazy coding.The goto function encourages messy coding. Adding a quick goto block instead of restructuring your code demonstrates lazy programming and makes it harder for others to interpret your code. And why is the goto block messy?If you have many different outcomes and need to reuse code, use nested ifs and definitions. Ever been in a situation where there is 100 different possible outcomes? Or when you don't want to repeat a block string again.. And again, and again… etc.
Um… Then you got this:if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
. . .
end
end
end
end
end
end
end
If you have that many possibilities, use lists and repeats.
- ev3coolexit987654
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
Also label could be used to crash the computer
label [crash1 v] ::control
goto [crash2 v] ::control
...
label [crash2 v] ::control
goto [crash1 v] ::control
- stickfiregames
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
That wouldn't crash it, it would just be an infinite loop. Try running Also label could be used to crash the computerlabel [crash1 v] ::control
goto [crash2 v] ::control
...
label [crash2 v] ::control
goto [crash1 v] ::control
when gf clickedwhich does pretty much the same thing - it won't crash at all.
broadcast [crash v]
when I receive [crash v]
broadcast [crash v]
- ChocolatePi
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
Do you understand them, or are you just saying that? No support for both.
Last edited by ChocolatePi (Sept. 11, 2015 00:20:54)
- MathlyCat
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
Could you please explain how your blocks work? I notice many people don't understand as not everyone knows what programming language they come from. I think that these should be some blocks:switch (variable :: variable) :: control cstart
case (1) :: control cstart
do something
:: cend
case (2) :: control cstart
do something
end
etc :: custom caplabel [label v] :: control
go to [label v] :: control
These ideas came from several scripting languages. (Batch (label block) and Javascript (switch block))
Yes, I know other people have submitted both of these.
Supporters:Idea 1 :: custom cstart
Scratcher1002 (duh :: operators) :: operators
end
Idea 2 :: custom cstart
Scratcher1002 (duh :: operators) :: operators
end
If you do explain them post them in the MAIN topic!
- Gaza101
-
500+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
Could you please explain how your blocks work? I notice many people don't understand as not everyone knows what programming language they come from.
If you do explain them post them in the MAIN topic!
Here goes…
Here's an example of the switch statement: the following…set [n v] to [3]…is the same as…
if <(n) = [1]> then
say [n is one!] for (2) secs
else
if <(n) = [2]> then
say [n is two!] for (2) secs
else
if <(n) = [3]> then
say [n is three!] for (2) secs
else
say [n is something else!] for (2) secs
end
end
endswitch (3) :: control cstart
case (1 v) :: control cstart
say [n is one!] for (2) secs
end
case (2 v) :: control cstart
say [n is two!] for (2) secs
end
case (3 v) :: control cstart
say [n is three!] for (2) secs
end
case (default v) :: control cstart
say [n is something else!] for (2) secs
end
end
Goto essentially just changes how far Scratch has got in processing the code, for example…
when green flag clicked
ask [What's your age?] and wait
if <(answer) < [13]> then
goto [0-12 v] :: control // Looks for the first label block it can find in the current script with the same message
end // (label can be before goto block)
if <(answer) > [19]> then
goto [20+ v] :: control
end
goto [13-19 v] :: control
label [0-12 v] :: control // Signifies where goto blocks should point towards
say [You're a child!] for (2) secs
goto [end v] :: control
label [20+ v] :: control
say [You're an adult!] for (2) secs
goto [end v] :: control
label [13-19 v] :: control
say [You're a teenager!] for (2) secs
label [end v] :: control
Last edited by Gaza101 (Sept. 11, 2015 17:53:15)
- Scratcher1002
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
Correct, finally SOMEONE gets it!Could you please explain how your blocks work? I notice many people don't understand as not everyone knows what programming language they come from.
If you do explain them post them in the MAIN topic!
Here goes…Here's an example of the switch statement: the following…set [n v] to [3]…is the same as…
if <(n) = [1]> then
say [n is one!] for (2) secs
else
if <(n) = [2]> then
say [n is two!] for (2) secs
else
if <(n) = [3]> then
say [n is three!] for (2) secs
else
say [n is something else!] for (2) secs
end
end
endswitch (3) :: control cstart
case (1 v) :: control cstart
say [n is one!] for (2) secs
end
case (2 v) :: control cstart
say [n is two!] for (2) secs
end
case (3 v) :: control cstart
say [n is three!] for (2) secs
end
case (default v) :: control cstart
say [n is something else!] for (2) secs
end
end
Goto essentially just changes how far Scratch has got in processing the code, for example…when green flag clicked
ask [What's your age?] and wait
if <(answer) < [13]> then
goto [0-12 v] :: control // Looks for the first label block it can find in the current script with the same message
end // (label can be before goto block)
if <(answer) > [19]> then
goto [20+ v] :: control
end
goto [13-19 v] :: control
label [0-12 v] :: control // Signifies where goto blocks should point towards
say [You're a child!] for (2) secs
goto [end v] :: control
label [20+ v] :: control
say [You're an adult!] for (2) secs
goto [end v] :: control
label [13-19 v] :: control
say [You're a teenager!] for (2) secs
label [end v] :: control


- ev3coolexit987654
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
I know how they work.Do you understand them, or are you just saying that? No support for both.
- CatsUnited
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
Great name would use. @CatsUnited What would it be named? The “bunch of ifs” block?

What about
if (var) :: control cstart?
elseif [1] :: control cstart
... // case 1
end
elseif [2] :: control cstart
... // case 2
end
else :: control cstart
... // default
end
end
- Znapi
-
500+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
I don't think a goto is necessary. Control flow blocks should be used instead; they are much more readable. That is why control flow statements like loops were made in the first place.
- iamunknown2
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
goto is outdated, and is only used in languages that were made before C was invented. And why is the goto block messy?
Goto doesn't work well in object oriented languages. What if I put a label in one script and a “goto” call in another script?
when gf clickedWould it stop the broadcast? Would it skip the wait for one second? Would it give up altogether and turn into an infinite improbability drive? It's too ambiguous (similar to why the broadcast boolean is on the list of rejected blocks), so no support.
do stuff
broadcast [something v] and wait
wait (1) secs
label [test v] :: control
say [something]
when I receive [something v]
goto [test v] :: control
If you can answer those questions, I've got another one for you: What if you put the label block in one sprite, and the goto block in another?
I know what the switch block is, but no support, as it's a bit too specific for something like Scratch.
Last edited by iamunknown2 (Sept. 12, 2015 07:47:22)
- Discussion Forums
- » Suggestions
-
» Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)