@peternlewis, unfortunately I am finding that in a number of Actions this does NOT work, if the Variable is undefined. These are the actions I remember:
Prompt for User
Display in Window
Display Notification
There may be others.
It seems that when the variable is empty, KM interprets it a literal text, showing, for example: "%Local__Varname%".
But they don't exist whether you use "%Variable%Local__Var%" or just "%Local__Var%". Yet KM returns an empty string when "%Variable%Local__Var%" is used.
If I can't use "%Local__Var%" everywhere, then it is of no value to me.
Well, since you brought up notion of using just "%Local Var%", you obviously understand the benefit. Any chance you might fix the token evaluation method to work with this in the future? Since it works with "%Variable%Var%", hopefully it is not too grievous of a change.
The problem is that I don't want to just convert any unknown token to nothing, that would be very confusing every time you mistyped a token.
I could special case %Local xxx% tokens, but that still has the same issue - if you just mistype the variable, the result will âdisappearâ. Which, I suppose, is true of any mistyped variable name in a %Variable%% token.
So I don't really like the idea of just returning nothing when Keyboard Maestro doesnât know what you are asking.
But isn't "%Local" as much an identifier as "%Variable"?
Plus, you are already using part of the variable name to be an indicator of the variable scope, re "Local" and "Instance".
If it is too hard, too time consuming, then no, it's not worth the effort.
Done for the next version. Tokens that start with %Local or %Instance but that do not match any token (which there are none) or existing local or instance variable will return an empty string.