--- On Fri, 9/24/10, John Dixon <dixo...@hotmail.co.uk> wrote:
> 
> How can I find out which stack called a library stack from
> the script of the library stack ?
> 
> thanks...
> 
> John Dixon
>     

Are you wondering which script issued the 'start using' command? Or which 
script calls one of the handlers in your library stack script?
I'm not sure about the first one, but you can solve the second riddle by  
looking at the 'executionContexts' local property.

I made a quick test stack "MyMain" with a single button, and a substack "MyLib" 
with a single scrolling text field.
Then I set the script of stack "MyLib" to:

##
on MyLibHandler
   put "<<< MyLibHandler" & return & \
          the executioncontexts & return & \
          ">>>" & return \
          after field 1 of me
end MyLibHandler
##

Then I went back to stack "MyMain" and set the script of the button to:

##
on mouseUp
   start using stack "MyLib"
   MyLibHandler
   stop using stack "MyLib"
end mouseUp
##

With all that set up, I clicked the button, and got the following in the 
scrolling text field of stack "MyLib":

##
<<< MyLibHandler
button id 1004 of card id 1002 of stack "MyMain",mouseUp,3
stack "MyLib" of stack "MyMain",MyLibHandler,17
>>>
##

So the second-to-last line gives you the control that called MyLibHandler, the 
name of the handler in which MyLibHandler was callezd, and even the line number.
Note that I said 'the second-to-last line' - because if we slightly change the 
script of the button in stack "MyMain" to:

##
on mouseUp
   RunMyLibHandler
end mouseUp

on RunMyLibHandler
   start using stack "MyLib"
   MyLibHandler
   stop using stack "MyLib"
end RunMyLibHandler
##

Then we get the following output instead in the scrolling text field:

##
<<< MyLibHandler
button id 1004 of card id 1002 of stack "MyMain",mouseUp,2
button id 1004 of card id 1002 of stack "MyMain",RunMyLibHandler,7
stack "MyLib" of stack "MyMain",MyLibHandler,17
>>>
##

The 'mouseUp' called 'RunMyLibHandler'; and this in turn loaded the library 
stack, called 'MyLibHandler' and unloaded it again. So the first line is the 
originating event, and the second-to-last line gives you the handler that 
actually called the handler in the library script.

HTH,

Jan Schenkel.
=====
Quartam Reports & PDF Library for LiveCode
www.quartam.com

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La 
Rochefoucauld)





_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to