Who Called Function?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
BrianMaher
Posts: 3
Joined: Fri Apr 21, 2006 2:12 pm

Who Called Function?

Post by BrianMaher » Sun Jul 12, 2009 10:12 pm

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sun Jul 12, 2009 11:24 pm

Hi Brian,

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

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

BrianMaher
Posts: 3
Joined: Fri Apr 21, 2006 2:12 pm

Post by BrianMaher » Mon Jul 13, 2009 10:56 am

Thanks Mark.

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Post by trevordevore » Mon Jul 13, 2009 2:18 pm

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.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

BrianMaher
Posts: 3
Joined: Fri Apr 21, 2006 2:12 pm

Post by BrianMaher » Mon Jul 13, 2009 3:01 pm

Hi Trevor,

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

Brian

Post Reply