# extra blocks for variables

We have this situation:

1. A block, that reports all variables.

and

You could use this block for example like this, so the output needs to be ringed:

2. A block, that says, if a variable is visible or not.

3. A block that reports the value of a variable.
(It should be similar to this: )

Block 3 can be written like so, unless there's something different going on with the "value of variable" block.

Blocks 1 and 2 could possibly be implemented using that Javascript function reporter but I don't know any Javascript.

this is actually something I want to do, and that last block has already been made, I can't remember who made it, but here it is.

and here's the xml

<blocks app="Snap! 5.4, http://snap.berkeley.edu" version="1"><block-definition s="variable %&apos;var&apos;" type="reporter" category="variables"><header></header><code></code><translations></translations><inputs><input type="%s"><options>§_getVarNamesDict</options></input></inputs><script><block s="doIf"><custom-block s="does variable %s exist?"><block var="var"/></custom-block><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>v</l></list><l>return this.variables.getVar(v)</l></block><list><block var="var"/></list></block></block></script></block><block s="doRun"><block s="reportJSFunction"><list><l>v</l></list><l>throw new ReferenceError(Variable \${v} does not exist.)</l></block><list><block var="var"/></list></block></script></block-definition></blocks>


the <does variable [] exist?> block is in the create variables in program library

I tried this, but it only worked, when you put a variable in a ring, not with a block that reports a ringed variable.

Thanks! This is very useful!

did you do this? because if you want it to report the value of the variable, you should unringify the block, so it should look like this

Do you have a variable and a variable reporter both named variable?

oh, um, yeah, here's everything but with the custom block named var