Page 1 of 1

Who Called Function?

Posted: Sun Jul 12, 2009 10:12 pm
by BrianMaher
Hi Folks,

I am new to Revolution and was wondering if there is a way in a function to tell who called the function (i.e. I want to see the current call stack)?

I have a function that finds the correct connected database and returns its ID to the caller. If for some reason the database is not connected I want to consider it to be a logic error and notify the user of the error with information that would be useful to me (the developer) so I can more easily figure out why the error happened (not that I ever expect it to happen but I do tend to program defensively).

Thanks, Brian

Posted: Sun Jul 12, 2009 11:24 pm
by Mark
Hi Brian,

The target returns the object that called the currently running handler.

Best,

Mark

Posted: Mon Jul 13, 2009 10:56 am
by BrianMaher
Thanks Mark.

Posted: Mon Jul 13, 2009 2:18 pm
by trevordevore
Take a look at the executionContexts Brian. It returns the chain of calls leading up to the current spot in a script where it is called.

Posted: Mon Jul 13, 2009 3:01 pm
by BrianMaher
Hi Trevor,

That is exactly what I was looking for. Thank you very much.

Brian