Discovery of calling routine

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
mvillion
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 74
Joined: Sun Feb 24, 2013 12:29 pm

Discovery of calling routine

Post by mvillion » Tue Jun 19, 2018 9:44 pm

If I have a script and it calls a function, can the function know what script called it?
This would be very useful in debugging.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2197
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Discovery of calling routine

Post by jmburnod » Tue Jun 19, 2018 9:55 pm

Hi,
You may use "executionContexts".
Best regards
Jean-Marc
Last edited by jmburnod on Wed Jun 20, 2018 6:49 am, edited 1 time in total.

Klaus
Posts: 10110
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Discovery of calling routine

Post by Klaus » Tue Jun 19, 2018 9:55 pm

Please check "ExecutionContexts" in the dictionary, I think this is what you are looking for!

mvillion
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 74
Joined: Sun Feb 24, 2013 12:29 pm

Re: Discovery of calling routine

Post by mvillion » Tue Jun 19, 2018 11:38 pm

Hi

Close but not quite

Consider this

Code: Select all

on Command01
 put theFunction() into theAnswer
end Command01

on Command02
 put theFunction() into theAnswer
end Command2

function theFunction
 return ThisText
end function
Can 'thefunction' know who called it?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2197
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Discovery of calling routine

Post by jmburnod » Wed Jun 20, 2018 7:05 am

Hi mvillion,
What about executionContexts ?

Code: Select all

function theFunction
  put item -2 of line -2 of the executionContexts into tHandler
 return ThisText && tHandler
end function

mvillion
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 74
Joined: Sun Feb 24, 2013 12:29 pm

Re: Discovery of calling routine

Post by mvillion » Wed Jun 20, 2018 9:16 am

Perfect. Thanks

Klaus
Posts: 10110
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Discovery of calling routine

Post by Klaus » Wed Jun 20, 2018 9:31 am

You're welcome! 8)

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”