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: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Discovery of calling routine

Post by mvillion »

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: 2734
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Discovery of calling routine

Post by jmburnod »

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.
https://alternatic.ch
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Discovery of calling routine

Post by Klaus »

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: 108
Joined: Sun Feb 24, 2013 12:29 pm

Re: Discovery of calling routine

Post by mvillion »

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: 2734
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Discovery of calling routine

Post by jmburnod »

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
https://alternatic.ch
mvillion
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 108
Joined: Sun Feb 24, 2013 12:29 pm

Re: Discovery of calling routine

Post by mvillion »

Perfect. Thanks
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Discovery of calling routine

Post by Klaus »

You're welcome! 8)
Post Reply