question about mainStack scripts

Sarah Reichelt sarahr at genesearch.com.au
Tue Aug 30 18:55:28 EDT 2005


>> In my main stack there is a preOpenCard handler.  Now, every time  
>> one  of my many subStacks is opened, the preOpenCard handler of  
>> the main  stack tries to run, and since it involves objects unique  
>> to that  stack, and the handler is trying to perform itself in the  
>> subStack,   I get an error, something like "oject doesn't exist, "
>>
>
> The script of the mainstack is accessible from all substacks,  
> acting as  a common repository of handlers, so what you're seeing  
> is normal.
>
> Three ways to have your mainstack-specific scripts only triggered  
> in the mainstack:
>
> - If the mainstack has only one card, consider putting the  
> mainstack-specific scripts at the card-level.
>
> - If the mainstack has multiple card you might consider adding a  
> shared group and putting its mainstack-specific stuff there.
>
> - You could also consider moving the mainstack and all of the  
> substacks into a new mainstack which is kept fairly minimal; that  
> way all of your stacks have their own discrete space, and you still  
> have a mainstack to use as a central repository.

and two more ways :-)

- as Eric suggests, have a check in the preOpenStack handler to make  
sure you are using the correct stack.

- have preOpenStack handlers in all your substacks (they can be empty  
if you don't need to do anything), and don't "pass" them. That will  
trap the preOpenStack handler message and stop it passing up the  
hierarchy to the mainStack.

Cheers,
Sarah




More information about the use-livecode mailing list