Page 1 of 1

Message hierarchy

Posted: Wed May 28, 2008 11:12 am
by hamlynart
Hi Folks,

I have a preOpenStack which sets the label of button 5 to the date. However it sets all buttons 5 on all substacks to the date too. I've tried setting the label of the button "thebutton" instead but then I get a "no such object" error. How can I stop the set label message going any further than the first card?

Many Thanks

Jim

Posted: Wed May 28, 2008 12:25 pm
by Janschenkel
That's the nature of mainstack and substack interaction: any message not handled by the substack script will pass on to the mainstack script.

You can either move your 'preOpenstack' handler to the first card of your mainstack, or you can check if the 'preOpenStack' message was sent directly to the mainstack or passed on from a substack:

Code: Select all

on preOpenStack
  if the target is me then
    set the label of button 5 to "Hello there!"
    -- any other mainstack specific initialization code
  end if
end preOpenStack
Hope this helped,

Jan Schenkel.

Posted: Wed May 28, 2008 12:59 pm
by Mark
Hi Jim

If you put the script at card level, it won't run when you open your substacks. If you want the script to run when specific substacks open, you could put a preOpenstack handler with a single command in the stack scripts of those substacks:

Code: Select all

on preOpenstack
  setLabel
end preOpenStack
and create a setLabel handler in the stack script of your mainstack, which sets the label.

Best,

Mark

Message hierarchy

Posted: Wed May 28, 2008 1:31 pm
by hamlynart
Thanks for that. I've added "of me" to the script which seems to have done the trick - I'm not quite sure why but if it works...!

Cheers

Jim

Posted: Wed May 28, 2008 1:49 pm
by Mark
Hi Jim,

Add "of me" should work, if you don't go to a card that doesn't contains such a button directly. If you open card 2 of your mainstack directly by script, you might encounter an execution error.

If you follow Jan's (or mine) advice, all should work fine and you might still add "of me" if you want.

Best,

Mark