Open Stack script

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
Glenn Boyce
Posts: 137
Joined: Thu Jul 24, 2008 11:22 pm

Open Stack script

Post by Glenn Boyce » Mon Mar 15, 2010 3:18 am

I have an openStack script that runs when I open a substack. I only want it to work when the main stack opens. How do I limit it to working just with the main stack?

cheers

Glenn

Regulae
Posts: 136
Joined: Tue Oct 20, 2009 6:05 am

Re: Open Stack script

Post by Regulae » Mon Mar 15, 2010 4:09 am

The following should work in your mainstack script:

Code: Select all

on openStack
   if the short name of this stack = "MainStackName" then
      -- the specific instructions you want
      pass openStack
   end if
end openStack
... “MainStackName” of course being the name you gave your main stack. The “pass openStack” is perhaps worth including if later you want to add instructions which only execute when opening substacks, e.g.:

Code: Select all

on openStack
   if the short name of this stack = "MainStackName" then
      -- the specific instructions you want
      pass openStack
   end if
   -- instruction when opening substack
   -- instruction when opening substack
end openStack
Regards,

Michael

Glenn Boyce
Posts: 137
Joined: Thu Jul 24, 2008 11:22 pm

Re: Open Stack script

Post by Glenn Boyce » Mon Mar 15, 2010 7:02 am

Many thanks

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Open Stack script

Post by Klaus » Mon Mar 15, 2010 1:48 pm

Hi Glenn,,

you can also put the "openstack" and "preopenstack" handlers into the script of the first card of that (main-) stack!
This way only the mainstack will get these messages (which do also get sent to the first card of the stack!).


Best

Klaus

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Open Stack script

Post by FourthWorld » Mon Mar 15, 2010 3:03 pm

Klaus wrote:you can also put the "openstack" and "preopenstack" handlers into the script of the first card of that (main-) stack!
This way only the mainstack will get these messages (which do also get sent to the first card of the stack!).
That's what I do. It's simpler than adding an IF condition, and keeps initialization handlers limited to a single script that can't interfere with anything else.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Regulae
Posts: 136
Joined: Tue Oct 20, 2009 6:05 am

Re: Open Stack script

Post by Regulae » Mon Mar 15, 2010 5:10 pm

Once again I learn something new. The Rev forum is both an education and an inspiration.

Cheers,

Michael

Post Reply