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:
Sub MyReportingMethod
try
raise new RuntimeException
catch err as RuntimeException
// err.stack(1) or err.stack(err.stack.Ubound - 1) has the calling method
end try
end MyReportingMethod
You’ll need to have IncludeFunctionNames checked in your build settings.