First-Time Initialization problem

David Burgun dburgun at dsl.pipex.com
Tue Oct 18 18:02:27 EDT 2005


Hi,

Here's something that has been driving me mad for a while now, I've 
managed to work-around it up until now, but now I'd like to know if 
there is a solution to it. I'd like to be able to run an 
Initialization handler in each card of a stack IF AND ONLY IF this is 
the first time the stack has been loaded.

I've tried call sorts to acheive this, using preOpenStack, openStack, 
preOpenCard, openCard, but none of it seems to work.

At the moment I have the following setup:

Script of card 1:

on openStack

send "StackInitialize" to this stack

pass openStack
end openStack

In the Stack Script:

on StackInitialize
local myIndex
local mySaveCard

repeat with myIndex = 1 to the number of cards in this stack
go to card myIndex of this stack
if the script of card myIndex of this stack contains "CardInitialize" then
   send "CardInitialize" to card myIndex of this stack
end if
go to card 1
end StackInitialize


This results in VERY strange happenings! Firstly the CardInitialize 
handler in each card gets called twice, I seem to remember that that 
the openStack handler in card 1 gets called twice? Is this correct? 
Secondly, the CardInitialize gets called when I do a goto card 1 from 
card 2. This seems to suggest that the openStack handler is getting 
called when the card is selected?

I've tried to debug this, but the debugger is SOOOOOOO flakey that it 
dies every time. Using answer dialogs don't help since they change 
the scope too and cause crashes.

Can anyone give me some advice on this?

Thanks a lot
All the Best
Dave



More information about the use-livecode mailing list