[scratchblocks]
run (JavaScript function [variableName][variableValue] @delInput@addInput [libVars = {}; libVars[variableName\] = variableValue;]::operators) with inputs (name) (value)@delInput@addInput::control[/scratchblocks]
for setting vars and
[scratchblocks](call(JavaScript function[variableName]@delInput@addInput[return libVars[variableName\] || false;]::operators) with inputs (name)@delInput@addInput::control)[/scratchblocks]
[scratchblocks]
run (JavaScript function [variableName][variableValue] @delInput@addInput [libVars = {}; libVars[variableName\] = variableValue;]::operators) with inputs (name) (value)@delInput@addInput::control[/scratchblocks]
will reset the libVars variable every time you set a variable in libVars.
Try using:
[scratchblocks]
run (JavaScript function [variableName][variableValue] @delInput@addInput [libVars[variableName\] = variableValue;]::operators) with inputs (name) (value)@delInput@addInput::control[/scratchblocks]
for multiple variables in libVars.
and to reset libVars use:
[scratchblocks]
run (JavaScript function @addInput [libVars = {};]::operators)@addInput::control
[/scratchblocks]
No, no, no! I bet you also think it's desirable to put comments in your code, but the former is the reason for the latter. Programs should be self-documenting, which means, among other things, that it should be clear from a variable name what the variable is for. One of the great things about block languages is that you can have a 200-character-long variable name, and you only have to type it once! (Of course this is also true if you have a good text editor such as Emacs so you can define abbreviations for the long names. You type the abbreviation and the editor inserts the long name into your code.
Long names translate to unwieldy blocks, which lead to hard to manage scripts. Without the ability to collapse sections of blocks, it leads to very unsavory block manipulations. Ever try to insert a block into another group which includes rather lengthy other blocks? The highlight won't let one accurately pick the exact location easily. It is much easier to edit when most of the script is of uniform shape and block lengths. imo.
I take your point, although expressions also become wide through composition of functions. For me (no surprise) that's more common than a problem with long names.
But also, there's long and long. The example that started this subthread was varName vs. variableName, and that's enough of a difference to be much more self-documenting, but not, I think, long enough to bring on the problem you describe.
There is no way to use Snap! "pictures" in ScratchBlocks. ScratchBlocks build dynamic SVG images. To change the blocks shape JS must be modified.
has easy and quite convenient features "script pic...", "result pic...", so ScratchBlocks slowly become obsolete.