PreOpenStack confusion

Dave Cragg dcragg at
Wed Feb 6 05:20:00 EST 2002

At 2:16 pm +1100 6/2/02, Michael J. Lew wrote:
>How do I set a clean-up operation to work when a stack is first
>opened, but not when I change to another stack such as a substack or
>even the documentation? My attempt using a preopenstack handler in
>the stack that I want to clean triggers whenever I open ANY stack,
>and of course fails because the false-triggering stack doesn't have
>the objects referred to in the clean-up routine.
>I want to (i) trigger the handler when the user first starts a
>particular stack, (ii) not have it operate when that stack is
>returned to from a different stack in a session, and (iii) only have
>it operate on the appropriate stack. These sound easy, but I can't
>see  a way to do it without conditionals testing the name of the
>stack and a global holding information regarding whether the
>clean-up has been run already. Surely it is easier than that!

Something like this in the stack script:

local lcStarted

on preOpenStack
  if the owner of the target is me then
    if not lcStarted
      myCleanUp ##your stuff here
      put true into lcStarted
    end if
  end if
end preOpenStack

The target of a preOpenStack handler is the card, so you need to 
compare its "owner" with the stack in question.

Dave Cragg
(Revolution -- It's got the power)

More information about the Use-livecode mailing list