It would help if you could explain a bit more about what you are doing.
Here are some examples of how to use the things suggested in this thread:
Script variables can be used to store information to be used later in the block's definition. Here is an example:
This saves the state of the pen and the location of the sprite and restores it after running.
Block Variables:
Block variables are unique because they are shared across every time the same instance of a block is called, but not every call on that block. This is more easily demonstrated like this:
Do you see what is going on here? Each time you see the block "counter", there is a different variable for that block.
This means that block variables are not very helpful when it comes to recursion:
I just whipped up a (probably not useful) recursive algorithm using block variables:
As you can see, this reports powers of two, skipping ahead the number of specified powers (here we skip 2, 8, 32, 128, and 512):
However, because the definition of the block shares the same instance of the recursion, another script can interfere/be interfered with:
By contrast, running the same script without first running the original example provides the intended result:
Well, actually, I just realized that it doesn't give the intended result, that my block doesn't actually work, but you get the picture of the issue with block variables in recursive algorithms. I give up on trying to figure out a recursive algorithm that might want block vars.
Linked Lists: