PreOpenStack confusion

Klaus Major kmajor at metascape.org
Wed Feb 6 03:21:01 EST 2002


Hi Michael,

> 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!
>
> Regards,
>
> -- Michael J. Lew

i hope i get your problem right...

You want to do some stuff with stacks, but only when they are opened for 
the first time.

Try to store the info (about the clean-up has already been run) in a 
customproperty of these namely stacks
(i love customprops, the best things ever ;-)


on is_it_clean the_stack   ## Name of the stack to clean here
    if the is_clean of stack the_stack then exit is_it_clean
    ...  ##your cleaning-stuff here
    set the is_clean of stack the_stack to true
end is_it_clean

If is_clean is true, your routine has alredy been run, if is_clean is 
empty,
then the stack is still muddy and dirty... :-)

Hope this helps.


Regards

Klaus Major
kmajor at metascape.org




More information about the use-livecode mailing list