After cursing LiveCode for a while and trying to glue what hair I still have left back into place, it was time to find out what I had done wrong.
I had forgotten about the message path in relation to Main and sub stacks.
Heres wahat happened.
In my Main stack I had a preOpenStack handler that initialized values and control positions.
Code: Select all
on preOpenStack
-- code to initialize the application
end preOpenStack
So I was about to code this into my sub stack and thought there must be a better way to do this, do I really have to trap the messge in each and every substack, No I did Not!
The answer is obvious, simple and elegant which is why I proberbly missed it, being entrenched in my coding habits.
All I needed to do was to check in the preOpenStack handler of the Main stack that the preOpenStack handler was initialized from the Main stack. so the code changed to:
Code: Select all
on preOpenStack
if the target is me then
-- code to initialize the application
end if
end preOpenStack
If the target function which determines which object originally received the message. In this case the main stack.
Is the same as Me that referes to the object that contains the current script, again the Main stack
Then run the initialize code.
So with this check in place I can now forget about adding trapping code to the sub stacks and have a much leaner and code safe app.
Moral of the story : The Message Path is your friend, unless of course you forget about it