Discuss Scratch

thebriculator
Scratcher
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] :: control
block and one
goto [hello world v] :: control
then you have to use a different ones like
label [play game v] :: control
and
goto [play game v] :: control
Scratcher1002
Scratcher
1000+ posts

Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)

thebriculator wrote:

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] :: control
block and one
goto [hello world v] :: control
then you have to use a different ones like
label [play game v] :: control
and
goto [play game v] :: control
OK, almost, you can have more than one goto block, BUT you can only have one label like this: Hello world
Then you have to do something like: helloworld
I was thinking for the label thing, it would be like the broadcast stuff.
scratchinghead
Scratcher
1000+ posts

Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)

Support both.
Econinja
Scratcher
1000+ posts

Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)

Scratcher1002 wrote:

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:

Scratcher1002 wrote:

[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.
That's not how we do that in Scratch. Most people (like me ) 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]


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]
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.
Scratcher1002
Scratcher
1000+ posts

Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)

Econinja wrote:

Scratcher1002 wrote:

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:

Scratcher1002 wrote:

[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.
That's not how we do that in Scratch. Most people (like me ) 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]


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]
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.

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
Scratcher
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
Scratcher
1000+ posts

Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)

support
Gaza101
Scratcher
500+ posts

Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)

Scratcher1002 wrote:

And why is the goto block messy?
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.

Scratcher1002 wrote:

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.
If you have many different outcomes and need to reuse code, use nested ifs and definitions.
Scratcher1002
Scratcher
1000+ posts

Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)

Gaza101 wrote:

Scratcher1002 wrote:

And why is the goto block messy?
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.

Scratcher1002 wrote:

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.
If you have many different outcomes and need to reuse code, use nested ifs and definitions.
I can understand why it maybe would encourage lazy coding.

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
Scratcher
500+ posts

Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)

Scratcher1002 wrote:

Gaza101 wrote:

Scratcher1002 wrote:

And why is the goto block messy?
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.

Scratcher1002 wrote:

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.
If you have many different outcomes and need to reuse code, use nested ifs and definitions.
I can understand why it maybe would encourage lazy coding.

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
Scratcher
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
Scratcher
1000+ posts

Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)

ev3coolexit987654 wrote:

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
That wouldn't crash it, it would just be an infinite loop. Try running
when gf clicked
broadcast [crash v]

when I receive [crash v]
broadcast [crash v]
which does pretty much the same thing - it won't crash at all.
ChocolatePi
Scratcher
1000+ posts

Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)

ev3coolexit987654 wrote:

No support for both.
Do you understand them, or are you just saying that?

Last edited by ChocolatePi (Sept. 11, 2015 00:20:54)

MathlyCat
Scratcher
1000+ posts

Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)

Scratcher1002 wrote:

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 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
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!
Gaza101
Scratcher
500+ posts

Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)

MathlyCat wrote:

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…

Gaza101 wrote:

Here's an example of the switch statement: the following…
set [n v] to [3]
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
…is the same as…
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

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
Scratcher
1000+ posts

Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)

Gaza101 wrote:

MathlyCat wrote:

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…

Gaza101 wrote:

Here's an example of the switch statement: the following…
set [n v] to [3]
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
…is the same as…
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

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
Correct, finally SOMEONE gets it!
ev3coolexit987654
Scratcher
1000+ posts

Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)

ChocolatePi wrote:

ev3coolexit987654 wrote:

No support for both.
Do you understand them, or are you just saying that?
I know how they work.
CatsUnited
Scratcher
1000+ posts

Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)

Scratcher1002 wrote:

@CatsUnited What would it be named? The “bunch of ifs” block?
Great name would use.

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
Scratcher
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
Scratcher
1000+ posts

Switch and label block (Supporters 2:2:2 for switch 2:1:1 for label)

Scratcher1002 wrote:

And why is the goto block messy?
goto is outdated, and is only used in languages that were made before C was invented.

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 clicked
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
Would 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.

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)

Powered by DjangoBB