%ExecutingMacro% and Sub-Macros?

Unless I’m mistaken, when used inside a Sub-Macro, the token %ExecutingMacro% returns the name of the top-level macro, not the Sub-Macro.

Is there a way to get the name of the Sub-Macro?

Hey Dan,

The only way I can think of is to build a trace system into your sub-macros.

Each call from the top-level through all the sub-macros would append a call-trace to a master-trace-variable.

Of course you can break that up as desired.

It looks to me that more and more folks are going to use sub-macro calls from a main macro, so it might behoove Peter to add a %ExecutedSubMacro% token to the mix.



why not just have the existing %ExecutedMacro% report for whatever macro the action is executed in?


Because one of the primary reasons for that token is so that sub macros can know which macro executed them. Macros know their own name anyway, so it’s really only a shorthand in that case to allow duplicating a macro without changing the name used within the macro, so it can always be worked around. Its a lot more difficult to work around figuring out the name of the parent macro that was executed.


Something like that, for sure.

Building a trace really doesn’t help, because I still don’t know what my macro name is. I really don’t want to hard-code the macro names, because they get changed all the time while I’m developing, and if someone else uses one, they may change the name also.