execution order of stacks

Richard Gaskin ambassador at fourthworld.com
Fri Aug 23 14:10:01 EDT 2002


Tony Moller wrote:

> Can someone explain the execution order of stacks, substacks, preopenstack,
> and openstack to me; cause what I think should work is not.
> 
> When opening a rev file, which consists of a main stack, and three
> substacks, what/which executes first? I know the preopenstack happens before
> the openstack, but what if the substacks have a preopenstack in them too?
> 
> Here's the structure:
> 
> mainstack (where the user will spend most of their time)
> substack (splash screen)
> substack (palette)
> substack (preferences)

The first card of the mainstack rec's the preOpenStack message first when
the stack file is opened.  Other stacks get the preOpenStack wheever your
scripts open them.

Note that the mainstack's script is available to all substacks, meaning a
passed or unhandled pre/openStack message rec'd by an opening substack will
trigger the mainstack's handler.   If this is undesirable, you can either
put an if statement in the mainstack's preOpenStack handler like:

  on preOpenStack
    if the short name of this stack <> "NameOfMainStack" then
      pass prepenStack
    else
     -- do stuff
    end if
    pass preOpenStack
  end preOpenStack

...or put the mainstack's preOpenStack handler in the script of the first
cd.
  
> What I want to happen is the splash screen show for x seconds, then close.
> Then the mainstack and palette substack should open. Prefs substack should
> be open (accessible) but hidden.  What's happening is the splash screen
> opens, along with the palette. Everything else seems to behave as it should.
> So, what commands need to be put where to execute in the order I would like?

Here's one way -- this would be in the mainstack script:

  on preOpenStack
    if the short name of this stack <> "NameOfMainStack" then
      pass prepenStack
    else
     InitApp
    end if
    pass preOpenStack
  end preOpenStack


  on InitApp
     toplevel "splash"
     send "CloseSplash" to me in 4 seconds
     open invisible stack "Prefs"
     palette "MyPaletteWindow"
     -- do other initialization stuff
  end InitApp


  on CloseSplash
    close stack "splash"
  end CloseSplash


PS: Why do you need the Prefs stack open invisibly?  Remember that you can
access objects and properties of stacks without explicitely opening them.
Accessing parts of a stack does cause the file to be read into memory, but
it is not officially open per se and so you don't need to worry about hiding
it.

-- 
 Richard Gaskin 
 Fourth World Media Corporation
 Custom Software and Web Development for All Major Platforms
 Developer of WebMerge 2.0: Publish any Database on Any Site
 ___________________________________________________________
 Ambassador at FourthWorld.com       http://www.FourthWorld.com
 Tel: 323-225-3717                       AIM: FourthWorldInc




More information about the use-livecode mailing list