principles of stack init

Ken Ray kray at sonsothunder.com
Tue Nov 23 01:03:33 EST 2004


On 11/22/04 11:37 PM, "thierry" <douez at wanadoo.fr> wrote:

> well, i don't like too much this way of doing..
> May be someone can give some others clues about
> how to Init or Reset a mainstack but not when
> you open or close substacks ?

The two "elegant" methods I've seen are these:

1) Don't put your openstack/closestack/etc. handlers in the *stack* script
of the main stack, but them in the *card* script of the main stack. Unless
your main stack has multiple cards, this will allow the messages to be
trapped by the mainstack when the mainstack issues them (since these
messages hit the card first and then go to the stack), but will *not* be
triggered by substacks (since the message goes to the card of the substack,
then the stack script of the substack, and then to the stack script of the
mainstack (bypassing the card script of the mainstack)).

2) I prefer to keep my openstack/closestack/etc. scripts in the stack script
of the mainstack - it's just how I think, I guess... but in order to trap
the messages properly and let the other ones slide, I do this:

-- mainstack script
on openStack
  if the owner of the target is me then
    -- do mainstack trapping of openStack
  else
    -- do substrack trapping of openstack, if you like
    pass openStack
  end if
end openStack

Since the target of the stack messages is the card, the "owner" of the card
needs to be the same as "me" (in this case, the mainstack) in order to do
mainstack stuff, otherwise you can do substack stuff or just let it pass.

So since I do #2, my modal dialogs (or other substacks) can simply execute
"close this stack" and not worry that the closeStack handler in the
mainstack will run inappropriately.

HTH,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list