Is there a Variable or Token for the Name of the Current Macro?

Is there a variable or token for the name of the current macro? I would like to be able to use that in debugging.

While using the debugger, I realized that I was not tracking when the activity of a macro or group ended and flow was about to return to the calling macro or group. I tried adding a comment at the end of the called macro, e.g., Comment: "End of Create Text to Paste in Log" and that seems to do the trick. The Debugger shows the comment action that lets me know when the sub-macro or group is complete.

But creating that over and over is tedious. I paste in a template comment at the end of the macro and then have to go all the way to the top of the macro and click Gear Icon > Rename and then copy the title and go all the way to the bottom again and paste it into the comment.

I'd really like to have a generic comment that I could paste in at the bottom of each sub-macro, something like Comment: "End of %%ThisMacroTItle%%" where that text would be substituted when the comment was displayed in the Debugger.

I suppose I could write a macro that would edit my macros this way, but it would be a lot easier if the variable or token already existed.

Yes indeed there are several tokens (at least 8) that identify macro and macro groups.

For instance:

Macro group:			%ExecutingMacroGroup%
Macro group UUID:		%ExecutingMacroGroupUUID%
Macro:					%ExecutingMacro%
Macro UUID:				%ExecutingMacroUUID%

Returns this:

Those specify the executing macro which. If you need to identify the macro that is a subroutine you would use %ExecutingThisMacro% etc.

See this wiki entry for more info. Demo macro below.

01)Scratchpad.kmmacros (2.7 KB)

Macro screenshot (click to expand/collapse)

3 Likes

Thanks Chris.

Are you saying that each of these:
%ExecutingMacroGroup%
%ExecutingMacroGroupUUID%
%ExecutingMacro%
%ExecutingMacroUUID%

has a corresponding "This" version:
%ExecutingThisMacroGroup%
%ExecutingThisMacroGroupUUID%
%ExecutingThisMacro%
%ExecutingThisMacroUUID%

??

Yes, you are. I just found them in the Wiki list of tokens. There are also three tokens about Instances and there is %MacroNameForUUID%<UUID>% which translates the UUID string into the text name of the macro.

Also, could you please clarify the phrase, "Those specify the executing macro which."

Now that I have the token names, I can do some experimenting to see if I can make something that does what I want, which is to show me in the debugger, or simultaneously with the debugger, when I have gotten to the END of a macro and am about to jump back out a level.

Thanks for the pointer.

My bad, apparently I didn't finish my train of thought :sweat_smile:

I meant those specify the executing macro which in this case is in the group Test Macros, and is called 01)Scratchpad.

For a more detailed example, here are two example macros. There is scratchpad, and scratchpad (subroutine). Run the scratchpad macro and it will call the subroutine, returning all 8 tokens, which will show you the differences.

Test Macros.kmmacros (5.7 KB)