jmoenig / Snap

a visual programming language inspired by Scratch
http://snap.berkeley.edu
GNU Affero General Public License v3.0
1.48k stars 739 forks source link

GUI issue on assigning variables #455

Closed overheder closed 10 years ago

overheder commented 10 years ago

I noticed several students today that tried graphically to program "Set 'variable' to ()' by dragging the variable they wanted to assign a value to onto the dropdown marker in the 'set variable' block. The drop down box is fine, but in an ideal world the GUI would allow dragging variable names and select the appropriate variable from the drop down list as a result of dragging.

While we're on nitpicking small issues, if there is only one variable declared in the program, all blocks should automatically populate with that variable name. Equally, sprite selections in e.g. sensors should be auto populated with the first valid item, not left blank. We already do this with integers used for motion (0 or 10 as default). This would be right 99% of the time for beginners, and save some frustration.

Again thanks for the tool, it enabled two 5th grade (11 yo's here) to embark on a journey into programming I had only hoped for three weeks ago.

Henrik

brianharvey commented 10 years ago

On 5/27/14 12:51 PM, overheder wrote:

I noticed several students today that tried graphically to program "Set 'variable' to ()' by dragging the variable they wanted to assign a value to onto the dropdown marker in the 'set variable' block. The drop down box is fine, but in an ideal world the GUI would allow dragging variable names and select the appropriate variable from the drop down list as a result of dragging.

It used to be, in BYOB, that dragging a variable onto a SET block meant to set, not that variable, but the variable whose name is the value of the first variable. That really confused everyone, so we made it not accept drops at all. I suppose we could special-case it to mean what you want, but it'd be different from how other blocks understand dropping a variable.

While we're on nitpicking small issues, if there is only one variable declared in the program, all blocks should automatically populate with that variable name. Equally, sprite selections in e.g. sensors should be auto populated with the first valid item, not left blank. We already do this with integers used for motion (0 or 10 as default). This would be right 99% of the time for beginners, and save some frustration.

Pulldown menus have to have a blank entry, because higher order functions use that to know where to drop argument values.

nathan commented 10 years ago

Pulldown menus have to have a blank entry

But that entry doesn't have to be the default.

overheder commented 10 years ago

Nice argument Nathan! IMHO this is not important, I am just out to limit frustrations and lower the barrier for beginners.

studej commented 10 years ago

@overheder And were your students successful in creating set "varReporter" to "value" block? Because it is possible to program that.

jmoenig commented 10 years ago

[edit] @studej I misread your original comment, sorry! So here's the corrected one:

@studej ... and here's how: You can build your own set "varReporter" to "value" block in Snap, using Snap's any (unevaluated) slot for the variable reporter, and run _ with _ to pass it to a variable setter block:

setvar

@overheder this might be a block you can let your students use, because it does what they expect...

studej commented 10 years ago

@jmoenig Yes, yes. This is the solution. I did not want to show it immediatelly :-)

Note for @overheder: You can also program other variable blocks as "change", "show" and "hide" by this way. In fact, you can use "run" command to pass value into "protected" dropdown menu input (as for example in connection with variables) which you can't fill normally with reporter as a user.

You can also for example create unary operators by using "call" function -- more here: https://github.com/jmoenig/Snap--Build-Your-Own-Blocks/issues/366

jmoenig commented 10 years ago

@studej Yeah, sorry, I misread your initial comment on this to mean that this couldn't be done in Snap! :-)

studej commented 10 years ago

Close this?

overheder commented 10 years ago

@studej , no they did not go as far - 3 times 1.5 hours of programming introduction, and I had patterns, crappy birds and stories told. The intricates block building was not part of their curriculum..

Anyway, thanks for the discussion, I understand the closure

Henrik