Which stack called the library stack ?

John Dixon dixonja at hotmail.co.uk
Fri Sep 24 17:32:04 EDT 2010


Thanks for your replies ... Dar, Richard, Jan....

I have a stack that contains a field.. what happens in the field is 
called from a library stack that is loaded in the preOpen stack 
handler...



What I want to happen is that the backgroundColor of the field will 
change depending on whether or not the stack is 'suspended'... I have a 
'suspendStack' and a 'resumeStack' handler in the library stack to 
handle the change of colour...



All works fine if I run the stack as a standalone ... 

All works fine in 
the IDE except for the first click in the field when the stack has first opened, 
for some reason the colour of the field when first 'clicking' into it 
changes the colour to the suspended colour ... all subsequent clicks 
after the first one and everything is fine...



So, the reason for me asking 'Which stack called the library stack' was 
that I was hoping I could trap for which stack was suspended or not and 
handle it that way...

regards

John Dixon


> Date: Fri, 24 Sep 2010 14:25:42 -0700
> From: janschenkel at yahoo.com
> To: use-revolution at lists.runrev.com
> Subject: Re: Which stack called the library stack ?
> 
> --- On Fri, 9/24/10, John Dixon <dixonja at 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 at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
 		 	   		  


More information about the use-livecode mailing list