Discuss Scratch
- Discussion Forums
- » Suggestions
- » Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
- Scratcher1002
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
I think that these should be some blocks:
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:
You want an explaination?
In Batch script, labels are defined like this:
:*whatever the label is called*
So, this might be a program:
:a
echo Say this.
cls
:b
goto :a
The program above will go through until the end of the program or you close the window.
LABELS WILL BE IGNORED UNLESS A GOTO SCRIPT IS PLACED then it will go to that label, and anything after the label. Now do you get it?
Good.
switch (variable :: variable) :: control cstart
case (1) :: control cstart
do something
:: cend
case (2) :: control cstart
do something
end
etc :: custom cap
label [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
You want an explaination?
switch block :: operators hatSo this:
switch (var) case (1 v) ::control cstartIs:
case (2 v)(-::control) ::control celse
case (3 v)(-::control) ::control celse
case (default v)(-::control) ::control celse
(+ ::control) ::cend// This was made by DaSpudLord
if <(var) = [1]> then
do something
else
if <(var) = [2]> then
do something
else
do something else
end
Label block :: operators hatLabel works like this:
label [hello v] :: control
go to [hello v] :: control
In Batch script, labels are defined like this:
:*whatever the label is called*
So, this might be a program:
:a
echo Say this.
cls
:b
goto :a
The program above will go through until the end of the program or you close the window.
LABELS WILL BE IGNORED UNLESS A GOTO SCRIPT IS PLACED then it will go to that label, and anything after the label. Now do you get it?
Good.
Last edited by Scratcher1002 (Sept. 11, 2015 03:03:01)
- wayyyy
-
500+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
I'm sorry, I don't know what these blocks do. 

- CatsUnited
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
Semi-support, but the switch statement would have to be renamed.
- DaSpudLord
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
I'm sorry, I don't know what these blocks do.
- scrooge200
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
I'm sorry, I don't know what these blocks do.
- Scratcher1002
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
OK, so, switch block.
Javascript uses the block like this:
Basically alot of ifs strung together but a more cleaned up version.
label:
So, you can do this script again if you want to.
Basically both of them clean up scripts.
@CatsUnited What would it be named? The “bunch of ifs” block?
Javascript uses the block like this:
Basically alot of ifs strung together but a more cleaned up version.
label:
So, you can do this script again if you want to.
Basically both of them clean up scripts.
@CatsUnited What would it be named? The “bunch of ifs” block?

Last edited by Scratcher1002 (Sept. 8, 2015 02:35:50)
- DaSpudLord
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
I still don't understand… OK, so, switch block.
Javascript uses the block like this:
Basically alot of ifs strung together but a more cleaned up version.
label:
So, you can do this script again if you want to.
Basically both of them clean up scripts.
@CatsUnited What would it be named? The “bunch of ifs” block?
Can someone else explain it?
- scratchinghead
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
I still don't understand… OK, so, switch block.
Javascript uses the block like this:
Basically alot of ifs strung together but a more cleaned up version.
label:
So, you can do this script again if you want to.
Basically both of them clean up scripts.
@CatsUnited What would it be named? The “bunch of ifs” block?
Can someone else explain it?
- Shock4
-
2 posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
I think they should have a audio sensing block (for example)
when green flag clicked
forever
change x by <audio loudness>
end
Last edited by Shock4 (Sept. 8, 2015 17:38:53)
- ev3coolexit987654
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
No support for both.
- Botcho_Otkho
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
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
- DaSpudLord
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
I still don't understand…
Can someone else explain it?
- Gaza101
-
500+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
Here's an example of the switch statement: the following…
Semi-support for switch. No support for goto (it's messy).
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
end
switch (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
Semi-support for switch. No support for goto (it's messy).
- DaSpudLord
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
@Gaza101, thanks for the explanation! I've used that block in the Mindstorms EV3 program, so now I know how it works. Anyway, no support because it's workaroundable and can be confusing. But, if it were to be implemented, it should look something like this (except the words should probably be changed so it's less confusing)-
switch (3) case (1 v)::control cstartThe plus and minus buttons would be used to add and remove cases. The reason for this and not your suggestion is because what if I did this-
case (2 v)(-::control)::control celse
case (3 v)(-::control)::control celse
case (else v)(-::control)::control celse
(+::control)::cend//There should be a plus sign there, don't know why it won't show up...
...
if <> then
case (2 v)::control cstart
...
end
end
Last edited by DaSpudLord (Sept. 8, 2015 21:20:14)
- thebriculator
-
100+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
Support Both. I know Java and C++ among others and the switch:case block is really useful. Also I've actually been in situations where the goto label block would be handy
- Scratcher1002
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
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
Semi-support for switch. No support for goto (it's messy).
Almost yes, it's:
switch (n) :: 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
And why is the goto block messy?
Yes, I know they are workaroundable.. BUT. 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.
- DaSpudLord
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
What do the label blocks do?
- Scratcher1002
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
The label blocks do this: What do the label blocks do?
Essentially it can be used as a forever block like this:
label [hello world v] :: control
do something
goto [hello world v] :: control
The label block basically cleans up scripts a little bit. The goto label block makes it so it goes to that label and does whatever is after the block until another label. AND 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.
- DaSpudLord
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
No support for labels- first off, easily workaroundable with loop blocks.
Also, like the switch block, it could confuse inexperienced Scratchers.
And, what would happen if I had multiple label blocks?
Also, like the switch block, it could confuse inexperienced Scratchers.
And, what would happen if I had multiple label blocks?
- Scratcher1002
-
1000+ posts
Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)
No support for labels- first off, easily workaroundable with loop blocks.
Also, like the switch block, it could confuse inexperienced Scratchers.
And, what would happen if I had multiple label blocks?
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.
- Discussion Forums
- » Suggestions
-
» Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)