This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-01-02 16:03:58

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

switch block

it would be like

____________
| switch ()  |
| case (): [-]|
|  | |_|
|  |_______
| case (): [-]|
|  | |_|
|  |_______
| default: [+]|
|  |  |_|
|  |__________
|____________|

and what it does is first it works out the value of the "switch" input. Then it checks each "case" input and if one matches the value that is in the "switch" bit, it runs the blocks in that input. If there is no match, it runs the blocks in the "default" bit. The - buttons next to each case will delete that case and the + button by the default will add another case.

supporters: 5

joefarebrother
scimonster
catperson
rdococ
veggieman001

Last edited by joefarebrother (2012-02-21 12:12:56)


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#2 2012-01-02 17:15:34

Purika
Scratcher
Registered: 2011-01-26
Posts: 100+

Re: switch block

It´s a nice idea!  smile


https://lh3.googleusercontent.com/-ZlPXbnYAtro/TxRNNopA6XI/AAAAAAAAAvY/worvlbyfCYI/s589/Purika.gif
If I was three birds, I could see myself fly below us!  big_smile

Offline

 

#3 2012-01-02 17:42:36

SJRCS_011
Scratcher
Registered: 2011-02-07
Posts: 1000+

Re: switch block

This is basically two nested "If Else" blocks, though.
A few more blocks won't hurt.


http://i.imgur.com/vQqtH.png
Learning to Program in a Nutshell:  "You're missing a closing parentheses" - LS97

Offline

 

#4 2012-01-03 16:41:21

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: switch block

SJRCS_011 wrote:

This is basically two nested "If Else" blocks, though.
A few more blocks won't hurt.

Not exactly. It works out the main value first, than works out the case values and compares them to the main value. You can also add more cases using the + button.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#5 2012-01-04 08:44:24

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Offline

 

#6 2012-01-04 15:25:01

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: switch block

scimonster wrote:

Yes.

does that mean you support?


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#7 2012-01-05 01:38:22

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: switch block

joefarebrother wrote:

scimonster wrote:

Yes.

does that mean you support?

scimonster wrote:

Yes.

Offline

 

#8 2012-01-09 16:21:37

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: switch block

bump


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#9 2012-01-09 16:42:26

CatPerson
Scratcher
Registered: 2011-12-17
Posts: 1000+

Re: switch block

AWESOME IDEA!!! I like blox that makes you use less time. LOL XD
                            Love,
                               CatPerson    /\_/\
                                                 I ' . ' I   i out # U ( nine lives )


http://nyopoliticker.files.wordpress.com/2012/02/in_dog_we_trust_rusty.jpghttps://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSrxH2RAmte9adghivuoOhgklIlUcZUFuCAA0wFufFq-NWyZWg5http://www.buttonsonline.com/2012/obama/BO-rallysign-104.gif

Offline

 

#11 2012-02-14 15:36:41

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: switch block

bump


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#12 2012-02-20 09:46:10

zakattack7
Scratcher
Registered: 2011-02-15
Posts: 16

Re: switch block

this already exists



 if <(blah) = (bloh)>
   if <(evil) = (funny)>
   go to [your doom v]
   else
     if <(mwahhaha) = (evil laugh)>
     go to [your room v] 
     else
     set [good v] to [evil]
     end
   end
 end
is that what you mean if so are you asking for the else if command witch exists in other languages but might be confuse to many kids witch is what scratch is meant for right?
but you can still  use this command by placing else and if blocks next to each other

Last edited by zakattack7 (2012-02-20 10:07:54)

Offline

 

#13 2012-02-20 14:09:48

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: switch block

zakattack7 wrote:

this already exists



 if <(blah) = (bloh)>
   if <(evil) = (funny)>
   go to [your doom v]
   else
     if <(mwahhaha) = (evil laugh)>
     go to [your room v] 
     else
     set [good v] to [evil]
     end
   end
 end
is that what you mean if so are you asking for the else if command witch exists in other languages but might be confuse to many kids witch is what scratch is meant for right?
but you can still  use this command by placing else and if blocks next to each other

no, this is the switch block in other programming languages, not the if/else block.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#14 2012-02-20 14:35:57

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: switch block

I love this idea and support, but it might be really confusing to new Scratchers and younger members  hmm


Posts: 20000 - Show all posts

Offline

 

#15 2012-02-20 14:37:12

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: switch block

However, the switch block is already makable with the if else blocks.

Offline

 

#16 2012-02-20 18:41:46

ProgramCAT
Scratcher
Registered: 2011-12-13
Posts: 500+

Re: switch block

You can do this already with the if/else blocks.


Programming is an art...
Goodbye, Scratch. I am leaving because of the exams coming up at our school, though I'll check the forums once or twice a week.

Offline

 

#17 2012-04-11 14:39:56

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: switch block

ProgramCAT wrote:

You can do this already with the if/else blocks.

yes, i KNOW you could just do

if <(switch) = [case1]>
do case1
else
if <(switch) = [case2]>
do case2
else
if <(switch) = [case3]>
do case3
else
if <(switch) = [case4]>
do case4
else

if <(switch) = [case5]>
do case5
else

if <(switch) = [case6]>
do case6
else

if <(switch) = [case7]>
do case7
else

if <(switch) = [case8]>
do case8
else

if <(switch) = [case9]>
do case9
else

if <(switch) = [case10]>
do case10
else

if <(switch) = [case11]>
do case11
else

if <(switch) = [case12]>
do case12
else

do default
But this can get VERY laggy if there are alot of cases, and you have to drag out loads of nearly identical structures to do this, and besides: the switch structure is in many, many programming languages anyway.

Last edited by joefarebrother (2012-04-11 14:41:20)


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

Board footer