Is there a way to change the name of a variable across many macros?

Is there a way to change the name of a variable across many macros? Essentially find/replace for variable names across many macros?

This post tells you how it can be done, but it's not easy:

Fundamentally, the reason this can't be done with variable names is that KM is so powerful that variables names can be constructed on the fly, or they can be buried deep within script actions. There is no way to "locate" a variable unless you actually RUN the macro, in some cases. Compare that with macro names - if you change a macro name it is immediately changed in all the Execute Macro actions across all macros, even if the macros are disabled. (Although if you put a macro name into a script, it won't catch that copy.) This prevents all kinds of programming errors, but means we have to go to a lot of extra work to execute a macro whose name is stored in a variable.

The Architect said 3 years ago that there was no plan for a general Find and Replace at this time.

However I'll tell you what I'll do. I have a sneaky way of creating a macro that runs in the background and can generate a beep whenever it "sees" a name of your choice on the screen. That will almost be half as good as a "Find" ability in the KM Editor. I'll go write it now, and place it into the Macros forum.

Try this new macro if you want the ability to search for words or variables in the visible portion of the KM Editor window...

Don't forget that you can use the Editor's "Search" box to find all the macros containing a certain string, and using the word: qualifier will reduce false positives. Matching actions within those macros will be highlighted for you, so an horrible job is at least made easier.

1 Like