Finding the calling code/object/script?
Peter M. Brigham
pmbrig at gmail.com
Fri Aug 23 09:10:55 EDT 2013
I was playing around with the executionContexts and came up with a more readable format for it, for anyone who's interested. The executionContexts returns something like:
button id 1053 of group id 1040 of card id 1002 of stack "/Users/pmbrig/Documents/LiveCode/pmbLib.rev",mouseup,114
group id 1040 of card id 1002 of stack "/Users/pmbrig/Documents/LiveCode/pmbLib.rev",doTest,7
altExecutionContexts returns something like:
button "test" of bkgnd "handlerGp" of stack "pmbLib",mouseup,114
bkgnd "handlerGp" of stack "pmbLib",doTest,7
Handlers below.
-- Peter
Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig
---------
function altExecutionContexts
-- returns the executioncontexts, in a more readable form
-- requires getprop robustName, q()
put the executioncontexts into tExecutionContexts
repeat for each line c in tExecutionContexts
put item 1 of c into tObj
put the robustName of tObj & comma & item 2 to -1 of c into tLine
put tLine & cr after tList
end repeat
return line 1 to -2 of tList
-- last line is the owner of this script, so ignore it
end altExecutionContexts
getProp robustName
---- a virtual property, read only ----
-- getting the long name of a control can result in different values depending on
-- (a) where the stack is stored on the user's disk and
-- (b) which card is the currentcard when the property is fetched
-- the robustName is consistent no matter what card is current
-- and no matter which folder the user has stored the stack in;
-- format: button "copyText" of bkgnd "fieldGp" of stack "substack1"
-- of stack "myMainStack"
-- the robustName can be used as a complete object reference,
-- just like the long name
-- requires q()
put the long name of the target into tLongName
replace " stack " with cr in tLongName
put line -1 of tLongName into mainStackFileName
if word 1 of mainStackFileName <> "stack" then
put "stack " before mainStackFileName
end if
put the short name of mainStackFileName into mainStackName
if tLongName begins with "stack" then
put q(mainStackName) into word 2 of tLongName
return tLongName
end if
put q(mainStackName) into line -1 of tLongName
replace cr with " stack " in tLongName
replace " of " with cr in tLongName
put lineoffset(cr & "card ", cr & tLongName) into cdLineNbr
if cdLineNbr > 1 then delete line cdLineNbr of tLongName
repeat with c = 1 to the number of lines of tLongName
put line c to -1 of tLongName into ctrlName
replace cr with " of " in ctrlName
put the name of ctrlName into line c of tLongName
end repeat
replace cr with " of " in tLongName
replace "group" with "bkgnd" in tLongName
-- in case the group is not placed on the currentcard
return tLongName
end robustName
function q str
-- quote
return quote & str & quote
end q
On Aug 22, 2013, at 5:55 PM, J. Landman Gay wrote:
> On 8/22/13 3:57 PM, Dr. Hawkins wrote:
>> On Thu, Aug 22, 2013 at 1:32 PM, Mark Schonewille
>> <m.schonewille at economy-x-talk.com> wrote:
>>>
>>> The executionContexts contains a list of all handlers and objects that
>>> called one of the handlers in the current chain.
>>
>> That is just perfect!
>>
>> word 1 of line 1 of the executionContexts is "field"
>>
>> when this happens!
>>
>> Thank you so much.
>>
>
> If this is just for debugging, you don't need to script it. Set a breakpoint, and the executionContexts appear in a popdown button at the top of the script editor. You can use that to backtrack through the script to see what called what.
>
> --
> Jacqueline Landman Gay | jacque at hyperactivesw.com
> HyperActive Software | http://www.hyperactivesw.com
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list