Message hierarchy

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
hamlynart
Posts: 101
Joined: Wed Mar 19, 2008 7:10 pm
Contact:

Message hierarchy

Post by hamlynart » Wed May 28, 2008 11:12 am

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

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Wed May 28, 2008 12:25 pm

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.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed May 28, 2008 12:59 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

hamlynart
Posts: 101
Joined: Wed Mar 19, 2008 7:10 pm
Contact:

Message hierarchy

Post by hamlynart » Wed May 28, 2008 1:31 pm

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed May 28, 2008 1:49 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply