Some questions concerning DEFINE (block)

  1. What did I do wrong to obtain this result? Memoize Metaprogrammed script pic (3)

  2. DEFINE () () () won't let you specify block variables. Is there any way to do this using metaprogramming?

Is that you looking for? (it work if the temp var is local or global but not script var)(it you don'y want a local/global var: use the create var lib to creating a global var and delete it after...)

@loucheman’s approach turns out to work. Can anyone explain why?

I think this is a bug, because if you drag the block out of the report bubble (report the block instead of the label), the block has the original label, but if you edit it, the edit dialog has the new label. There are two different effects if you save and reopen the project. If you edited the block, and pressed ok, the block goes to the new label (after reloading), but if you don't edit it at all, the block becomes undefined. Also, block is red when undefined in a ring, but if you drag it out, it becomes grey, idk why.

This is weird as well: … when compared to my original post:

untitled script pic 90 untitled script pic 91

Looks a bit like quantum mechanics!
Definitely an undocumented feature :wink:

You know that the block template (held on the palette) becomes "indiana pie" after running your script?
But the "block" instance, a copy returned from the "define", is not updated.
untitled script pic - 2023-06-03T194425.131
"set label of block" searches and updates all global instances, whether they are part of the scripts or referenced by the global variable. But upvar is a script local variable ...

Surely, I noticed.

In some cases it is, in others it isn’t: see the two implementations in post #5.
Which is weird.
More generally: untitled script pic 94 shouldn’t influence any subsequent values of B.
However, if B is a pointer (and therefore A and B are going to point to the same object), if subsequently any operation is applied on the object A points to, this will by definition have consequences for the object B points to (since it’s the same object). But in this case, after the assignment nothing happens to A, and still the very assignment apparently influences B (or what it points to). This is so strange to me that I compared it to quantum mechanics,

And how about this?

untitled script pic 96 untitled script pic 98

What is your position regarding this issue?
I’m not sure how to interpret your post. Are you (@dardoro) trying to convey that Snap!’s behaviour is explicable? Or are you merely making observations?