Is it possible to determine the name of a procedure or function that is running?
(For you C programmers, something akin to the
I’ve gone through
Info("ProcedureStack"), but it, unfortunately, does not include the original caller in its stack.
If: ProcedureA calls ProcedureB Then: Info("ProcedureStack") in ProcedureB returns "ProcedureB"
Info("ProcedureStack"), when called from ProcedureB, includes ProcedureA and ProcedureB.
If: ProcedureA calls ProcedureB which calls ProcedureC Then: Info("ProcedureStack") in ProcedureC, returns "ProcedureB" and "ProcedureC"
Info("ProcedureStack"), when called from ProcedureC, includes ProcedureA, ProcedureB, and ProcedureC.
CallingProcedure() also does not return what’s expected.
If: ProcedureA calls ProcedureB Then: CallingProcedure() in ProcedureB returns an empty string
CallingProcedure(), when called from ProcedureB, returns ProcedureA.
If: ProcedureA calls ProcedureB, which calls ProcedureC Then: CallingProcedure() in ProcedureC returns "ProcedureB"
Expected result: Exactly what happens. (IOW, this works)
Next to “CallingProcedure()”, it’d be nice to have something like “CurrentProcedure()” that returns info about the currently running procedure or function.
Why would I want this? Glad you asked …
I’ve got a very simple logging function that writes information to a log file as the program runs.
It would be nice if each statement could automagically write out the procedure name without requiring the calling procedure to provide the procedure/function name in a
Thanks for listening …