Is there a way to pass the name of the currently executing method to another routine as a parameter? For example, if I have a global routine that puts up a message box that says xxx routine did something, how do I pass the calling method name so the ‘xxx’ has the calling method’s name?
I’ve search the forums but can’t seem to find the information.
Would be cool if there were a pragma for this… But there’s an easy approach. Raise an exception in a “try” block, catch the exception, peel the name off the stack. Something like:
raise new RuntimeException
catch err as RuntimeException
// err.stack(1) or err.stack(err.stack.Ubound - 1) has the calling method
You’ll need to have IncludeFunctionNames checked in your build settings.
Sounds like you want the CurrentMethodName method.
D’OH, Andrew beat me to it.
Well, then he has to pass it as a parameter. He actually needs the method calling the current method. But yeah, that could work with a parameter.
Yeah there’s no “who called me” … you know that
Thanks, everyone. Actually passing the method name as a parameter will work just fine for what I need.