The issue here is not about creating variables. The issue here is:
Why does KM delete a global variable, if it's empty?
According to this reply:
Empty variables are completely deleted
But variables set to %Delete% are not deleted
Wait... what? So empty = deleted, but %Delete% = not deleted
Peter's words, not mine:
"In Keyboard Maestro, if you set a variable to the empty string, then the variable is removed and no longer exists.
If you set it to “%Delete%” then the variable exists, but its display in variable lists is suppressed, and its value is functionally empty."
My issue with this, as I mentioned, is that global variables can cause big issues if they are not available on the list, but are being used in a macro.
For example, let's say I set a global variable called "list".
And every day of the week I like to add book titles to that variable. Then Sunday night I run a macro that grabs all that info and creates a .txt file with all those titles. After that, I want the variable to be empty again, because I do that every week.
Now, of course, after a while I don't remember what the name of the global variable is, because I just run the macro, I'm not looking at the variable name.
Then one Monday (when the variable is supposed to be empty, but because it's empty, it also disappeared from the variables list) I decide to create a new macro and I also need a global variable. I go to my variables list and I see that there's no "list" variable variable. Great. I create the macro, add an action to create a "list" variable.
Then Tuesday, Wednesday, etc, I keep running the 1st macro to add book titles, but I'm also running the second macro everyday, also using a variable called "list". I guess you can see where that goes, right? They are both using the same variable. Mess!
If I were able to have an empty variable that's visible on my list of variables, I would know that some macro is using the variable "list" and I would pick a different name.