preOpenStack, openStack in Card 1?? Rules conformation.
dburgun at dsl.pipex.com
Thu Mar 30 10:45:30 CST 2006
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
> 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
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?
> For readability I tend to structure my initialization like this:
> on preOpenStack
> end preOpenStack
> on InitApp
> end InitApp
> ...where each of those "Init*" handlers are also included the card
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
Yes, it helps a lot!
More information about the use-livecode