Has anyone ever suggested a new control block, 'Case'?
There are many times when I have many 'ifs' one after the other, which are basically all checking the result of just one test and then selecting one out of set of different actions.
A 'Case' statement would really tidy this up.
<Case[test_something]>
<when> result1 do action1
<when> result2 do action2
<when> result3 do action3
<end-case>
Offline
Yes, but then you have to keep repeating the test in EVERY if!
The whole point of a 'Case' statement is that the test, (epecially a long and complex one), is programmed once and then each of the 'when' statements just checks for the results. ;-)
Offline
I totally support this idea. Many programming languages have select-case or switch-case structures and Scratch focuses on learning programming. And there's plenty of room for improvement on the controls section
Screenshot!
That would be so cool!
EDIT: From the third 'case' a '-' sign should be shown to remove it again.
Last edited by JSO (2009-12-19 17:35:54)
Offline
JSO wrote:
I totally support this idea. Many programming languages have select-case or switch-case structures and Scratch focuses on learning programming. And there's plenty of room for improvement on the controls section
Screenshot!
http://img687.imageshack.us/img687/3227 … mockup.png
That would be so cool!
EDIT: From the third 'case' a '-' sign should be shown to remove it again.
So if the input in the first case statement was "1", then the block would do the action inside of that?
Offline
I would love to see a 'case' block in Scratch. I support this idea.
Offline
The-Whiz - Yup
http://en.wikipedia.org/wiki/Switch_statement
This is about the Switch statement (Switch-case), which is the same as Select-case.
Select seems a better name for use in Scratch because "select" describes it better then "switch" does when learning programming.
Offline
I support this.
JSO: Good logical reasoning.
Offline
I remember asking for this sort of thing in v1.1. Its not the top priority but it would help speed some things up.
Offline