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
Message hierarchy
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
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:
Hope this helped,
Jan Schenkel.
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
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
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:
and create a setLabel handler in the stack script of your mainstack, which sets the label.
Best,
Mark
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
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Message hierarchy
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
Cheers
Jim
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
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode