# Making a Custom Block with an Identifier Menu (variable name)

Hello Snap! community

I'm trying to make a decrease <variableName> block, that decrease the given variable by -1.
My goal is to make a custom block that do it, not to use the block change <varName> by -1.

I would like to put a slot menu for choosing the variable name inside the custom block decrease var.
Is this possible ?

(the varName is Any Type in the screenshot)

Just copy-and-paste this into a text editor and save as an .xml file:

<blocks app="Snap! 6, https://snap.berkeley.edu" version="1"><block-definition s="decrease %&apos;VAR&apos;" type="command" category="variables"><header></header><code></code><translations></translations><inputs><input type="%s" readonly="true"><options>§_getVarNamesDict</options></input></inputs><script><block s="doRun"><block s="reifyScript"><script><block s="doSetVar"><l></l><l>-1</l></block></script><list></list></block><list><block var="VAR"/></list></block></script></block-definition></blocks>


Just do this in the custom block:
[scratchblocks]
[/scratchblocks]

The missing part ...

how did you get flat design menus on the default GUI design?

Flat only.

// ==UserScript==
// @name         Snap! Dark Flat
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Dark Flat Mode
// @author       Sanp! source || DarDoro
// @match        https://snap.berkeley.edu/snap/snap.html
// @icon
// @grant        none
// ==/UserScript==

(function() {
IDE_Morph.prototype._setDefaultDesign ||= IDE_Morph.prototype.setDefaultDesign;
IDE_Morph.prototype.setDefaultDesign = function(){
this._setDefaultDesign();
MorphicPreferences.isFlat = true;
};
})();


It's still weird to me that change x by -1inside the custom block definition don't work with x a variable like in @dardoro answer.

I read the faq and I agree that it don't make any sense, but I was rather thinking of something like :

which does not work, I wonder why and if there is any decision behind it.

Suppose you put a SAY (NAME) at the end of your script. Then you call your DECREASE block with the input 5. So you start out with NAME=5, and then you CHANGE [NAME] BY (-1). What would you expect the SAY block to say? "4," right?

Now call your block with the input FOO. So you start out with NAME=FOO and you try to subtract 1 from that value, and it doesn't work because the value is a word rather than a number.

I think, attempting to read your mind, that you think putting the block in the Variables category (the orange blocks) gives it some special variable-nature. Or you think that because you called the input NAME, Snap! will realize that you meant it to be the name of a variable and "do the right thing." But no, it tries to do the same thing it did for 5, which doesn't work.

So it's not so much a "decision," as you label it, but rather just a working-out of the way things happen in the absence of a decision. Except for the decision not to allow putting variable ovals in those slots at all, since everyone gets so confused about it. The people who learn not to be confused can use the CALL WITH INPUTS form.

For the other menu items everything works as expected.

Confusion is still there as (varName is a built-in menu)

has a scope issue.

This way, as unevaluated, works as expected because of special case handling