Discuss Scratch

Scratcher1002
Scratcher
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 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 hat
So this:
switch (var) case (1 v) ::control cstart

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
Is:
if <(var) = [1]> then
do something
else
if <(var) = [2]> then
do something
else
do something else
end

Label block :: operators hat

label [hello v] :: control
go to [hello v] :: control
Label works like this:

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

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

wayyyy wrote:

I'm sorry, I don't know what these blocks do.
scrooge200
Scratcher
1000+ posts

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

DaSpudLord wrote:

wayyyy wrote:

I'm sorry, I don't know what these blocks do.
Scratcher1002
Scratcher
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?

Last edited by Scratcher1002 (Sept. 8, 2015 02:35:50)

DaSpudLord
Scratcher
1000+ posts

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

Scratcher1002 wrote:

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?
I still don't understand…

Can someone else explain it?
scratchinghead
Scratcher
1000+ posts

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

DaSpudLord wrote:

Scratcher1002 wrote:

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?
I still don't understand…

Can someone else explain it?
Shock4
Scratcher
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
Scratcher
1000+ posts

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

No support for both.
Botcho_Otkho
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
DaSpudLord
Scratcher
1000+ posts

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

DaSpudLord wrote:

I still don't understand…

Can someone else explain it?
Gaza101
Scratcher
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…
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

Semi-support for switch. No support for goto (it's messy).
DaSpudLord
Scratcher
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 cstart

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...
The 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-
...
if <> then
case (2 v)::control cstart
...
end
end

Last edited by DaSpudLord (Sept. 8, 2015 21:20:14)

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

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

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

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

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

What do the label blocks do?
Scratcher1002
Scratcher
1000+ posts

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

DaSpudLord wrote:

What do the label blocks do?
The label blocks do this:

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

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

DaSpudLord wrote:

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:

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.

Powered by DjangoBB