Multiple upvars

I can't seem to make multiple Upvars while making a custom block.
I'm trying to make a block that acts like the Script variables block, but there is no option to make multiple Upvars.

Can anyone help me make this possible?

It's not a feature available to us muggles unfortunately :frowning:

Do you want it to default to a,b,c like the script variables block, or something else?
Edit: Nevermind, apparently multi-upvars don't really work in custom blocks. Sorry.

This is possible by modifying the XML, but it's buggy and useless.

Other than that... Is it possible to modify it using Javascript? (Javascript really is common...)

If you want the block to be the same every time you load the project, no. Also, don't rely too much on Javascript, because it can get annoying having to enable it constantly.

You can just make the actual upvar a list, so instead of upvar 1, upvar 2, upvar 3, it's items 1, 2, and 3 of the greater list upvar.

it requires block hacks and gives the names of variables, it doesn't actually work like a proper upvar.
in this project, i have a custom block in the variables section LET (a) = [] that has multiple upvars, it uses some continuation and metaprogramming nonsense to work
there was some js thing somewhere on the forums that made a nice ui for all the broken block inputs, but i can't find it now. i swear i had it bookmarked.

why do you want multiple upvars though? are you sure you don't just want a list?

Enable Javascript constantly?

I use Javascript commonly on my projects (cuz most of the blocks can't do what I want). If only I could get a script to constantly enable it...

I'm trying to make a "script list" block, which has multiple script variables that have empty lists in each variable (so we don't have to constantly add set var blocks everytime we want to make a list only for that script)

Believe me, that's easy to find if you look at the source code and create a userscript. The only reason it's not enabled by default is to protect against malicious projects (it was added because of a malicious project). The snap team wants the user to look through the code and decide if it's safe to run.

But, to be honest, I don't look through projects before enable js

It means:If this asks for file downoading or passwords don't allow

should be easy to modify the LET block i sent to make a bunch of empty list variables

in the next release coming up end of this month / next week JavaScript is going to be always enabled by default if you use Snap! locally, i.e. if you download the repo and open it as file in your web browser. Does that help?

That one is very helpful, especially fot projects that use alot of Javascript to work. Which is commonly my projects.

is that safe? i'm imagining someone downloading and using a bunch of projects (such as a teacher trying a student project) and some project is trying to do something nasty.

Yeah you have a point. @jens, add a toggle for automatically enabling Javascript when shift+clicking settings.

I'm assuming it to be safe enough to use JS offline, because that way it won't be able to harm your cloud account.

Replying to post 7 - For what it's worth ... I wrote a different, perhaps more classical, version of LET, creating and initializing exactly one local variable:

RPS algorithm developer script pic

... to be used like:

RPS algorithm developer script pic (1)

... as an alternative for declaring a SCRIPT VARIABLE and initializing it subsequently in a separate block, like:

RPS algorithm developer script pic (2)

My LET-block has at least two limitations:

  1. only one variable can be created - or they would have to be nested, like:
    RPS algorithm developer script pic (3)
    … or, using a modified LET-block with inline command instead of c-shape:

    (unless @sarpnt has a brilliant alternative :wink: ).

  2. if one moves a variable or reporter block near the script encapsulated by the LET-block, a square white veil pops up over the script; with accidental release of the mouse button, the variable / reporter block will nest itself inside the LET-block’s C-shape, throwing out the existing code.
    N.B. primitive blocks with C-shapes (IF, FOR, REPEAT, etc.) have much better manners: no white veil, no accidentally throwing out code.
    @jens: Perhaps the Snap! team would be willing to build these good manners into all C-shaped parts of custom blocks?

@jens: far better than any LET-block: couldn’t the SCRIPT VARIABLES block be extended so as to support variable initialization (and possibly: declaring constants)? like:

(admittedly these latter two suggestions, as well as a request for enabling “multiple upvars”, belong in the Feature Request section of this forum)

could someone make a project that uses js to break the next loaded/saved project or imported files?