Convert Local Variables to Global Variables and Vice Versa

Howdy folks,

If you're like me, when you're building a macro you may like to use global variables to be able to see their value in real time to make sure everything works properly. However, you may want to convert those to local variables when you're done building the macro, or vice versa if you have to edit an already built macro.

This macro is not magic in that it will not automatically convert all those variables with no user input, but it will somewhat reduce the time it takes for you to convert them. For me, the longest part of this process was simply deleting the prefix I would use for my debug variables and typing local_, and I got tired of mistyping and not realizing it until the macro stopped working, and then having to track down that one variable that was called locl_iHateTypos instead of local_iHateTypos. :laughing:

All you have to do is click in the field where your variable is, and trigger this macro. It copies the text to the clipboard, and then uses a simple search and replace feature to replace local_ with debug_ and vice versa. The same macro accomplishes both purposes depending on if you continue to hold the modifier keys after triggering it or not (or your user prompt selection if ran from the Group's Menu Bar). More information on this in the macro comments.

I have used this already in a variety of macros and it seems to work fine for me. However, use with caution the first few times you use it because...well, you just never know haha. Let me know if you have any issues, questions or suggestions!


Variables- Convert Debugging to Local (for export).kmmacros (15 KB)

1 Like