Local and instance variables in the editor

I have been writing longer macros lately and so took the time to become familiar with Keyboard Maestro's local and instance variables. One sprawling thread (KM8: Local and Instance Variables) helped me ponder why scope is specified as part of the variable name rather than by some system of flags within the editor (I eventually decided that it provided high compatibility with scripting options, for a start), and it also revealed that for a while, KM made it possible to use a pair of ungainly single characters to replace the prefixes "local" and "instance". Some replacement character schemes were suggested in the thread but these came to nothing (they did strike me as unsuitable for various reasons).

As a newcomer to the world of typing ungainly instance variable names, I consider that the main problem with the long prefix (metadata about scope) is that it is a distraction from the data part of the variable. I would suggest that this is not of great significance within any script that refers to such variables, but that improved legibility in KM's editor would be helpful. Suggestion: render the data part of the variable name ("foo") in bold..?

If there is still a desire for shorter variable names, maybe add the ability to use "loc foo" and "inst foo", but of course with the risk of clashing with somebody's existing macros.

K.

Noted. I'm not sure it will ever happen.

Note that one definite advantage of using Local and Instance in the variable name is that you can safely refer to them with the short form of Variable tokens, ie, you can use %Local Path% rather than the longer version of %Variable%Local Path%. Because that will never conflict with any built in Token (eg, using %Path% works, but runs the risk that I might add a %Path% token in the future which would take precedence).

1 Like

I know the feeling! :laughing:

Ah. so that's why the long form is considered the better practice for global variables. Although I could start naming those using "𝔾", you won't be using that. :wink:

Many thanks
K.

1 Like