Ideas to help out editing complex and large projects

I'm wondering if some time and effort could be found into making it a bit easier on my poor wrist/fingers/brain when editing a large and complex project :slight_smile:

I have a lot of variables and to get down to the variable category blocks takes a bit of scrolling.

My suggestion for helping with this is be able to hide/unhide the variables

Also, could the variables be sorted

preferably with a line between global and local?

Also having the sprites in sorted order would help as well
image

I don't know how viable this is. Just sorting the list is probably the best thing to do.

ill try to see what i can do. my advice is try key : value lists, which you can nest / group.

i do agree though, i try to avoid global variables if i can because it just gets crowded and disorganized. it would be nice to have more control over what shows up where.

Thanks but this isn't a request for some user level JavaScript :slight_smile:

If you change the block size, will that make it larger?

The variable list? Cause I don't think changing block size will make lists larger.

When I say lists, I mean option menus.

yea yea.

heres a project with the associative arrays ive been using alot lately. thats been my go to method of organizing properties and such. you can ignore the js block in the first definition, and dont worry i left the dropdown menus alone. so instead of showing a list of keys for the list, it shows nothing. dont know how else to do it in normal snap. im sure youll figure it out, good luck.

If you are annoyed by this, the make variabels library in snap has a operator that allows you to type a variable name as text, you can put it inside the set [varname]

With block
untitled script pic - 2022-05-15T211338.353
you can select variable with the hardcoded menu values or just type the name

a={
a
aa
aaa
}
b={
b
...

menu
.
With unevaluated input you can drop variables from the palette or local vars declaration ...
untitled script pic - 2022-05-15T213540.478

.
Or create a kind of the bacpack with handy variables then copy (or "copy on drag" with user JS script)
menu

.
Of course with JS this idea can be further enhanced.

using the Create Variable library, it is as easy as this;
image

But why, while vanilla Snap! can do the same?
And the "create variable" library is slightly controversional.

How is it controversial?

Another way
image

That’s using the create variables library’s primitives, though.

Jens hates it.

His reasoning is that when people use it, they're trying to turn Snap! into a text language like whatever they learned previously. When you find yourself with a lot of global variables (or even a lot of local ones!) you should probably build a dictionary instead (a list of key-value pairs) instead. Then you just have one variable.

This is especially true when the variables are related to each other. For example, if you have a bunch of variables named RED, ORANGE, YELLOW and so on, with RGB vectors as their values, they should clearly become one variable COLORS with a dictionary as its value. Besides reducing clutter, this would allow you to add colors to the list, such as MAROON or TEAL, without having to change your code.

Wait til jens finds out about other blocks having text fields

I see his point (not to the degree that I hate the create-var library, on the contrary, I find it super useful sometimes)- it's much easier to just use one variable like a table then n other variables. Anyway.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.