preOpenStack, openStack in Card 1?? Rules conformation.
David Burgun
dburgun at dsl.pipex.com
Thu Mar 30 11:45:30 EST 2006
Hi Richard,
On 30 Mar 2006, at 17:20, Richard Gaskin wrote:
> For behaviors specific to my mainstack, I tend to put those in the
> mainStack's card script (or if there are multiple cards in my
> mainStack -- rare for me since I tend to use the mainStack as a
> repository of handlers -- I use a group in the mainStack). I do
> this because the mainStack's stack script is available to all
> substacks, and the alternative requires a decision point ("if the
> short name of the target is the short name of me"); to minimize
> complexity I try to keep decision points to a minimum (more on code
> complexity and its implications for maintenance coming in an
> article at revJournal soon).
>
I don't tend to use sub-stacks but I do use multiple cards. I tend to
have a new mainStack (e.g. separate .rev files) for each main window.
Although I will could use sub-stacks in the future if there were a
good reason.
> Initialization of course needs to be done only once, and the
> mainStack's first card will be the first recipient of the startup,
> openStack, and preOpenStack messages. The startup message is only
> sent at runtime (the IDE gets it in development), so to get
> initialization in both development and runtime I use preOpenStack
> instead.
>
I use preOpenStack to initialize the app too. I have the handler
defined in Card 1 of the (only) mainStack, so this should work if I
add sub-stacks? I hadn't really thought about it, I'm not sure if the
mainStack should initialize itself and all it's sub-stacks or whether
sub-stacks should initialize themselves when they opened.
Also I am not clear of the path the preOpenStack and openStack
handlers take. For a mainStack I'm guessing its:
mainStack:Card1:preOpenStack and if not defined mainStack: preOpenStack.
But how about a sub-stack?
subStack:preOpenStack ??
> For readability I tend to structure my initialization like this:
>
> on preOpenStack
> InitApp
> end preOpenStack
>
> on InitApp
> InitGlobals
> InitFonts
> InitColors
> InitWindows
> InitMenus
> end InitApp
>
> ...where each of those "Init*" handlers are also included the card
> script.
I do it like this too.
>
> As a matter of tidiness I usually pass all system messages, in case
> some other object is added down the road which needs them. With
> initialization, however, I prefer that everything be handled in one
> place so I don't pass that preOpenStack message.
>
> I'm not sure if this is exactly what you were looking for; hope it
> helps.
Yes, it helps a lot!
Thanks Again
Dave
More information about the use-livecode
mailing list