open and close stack command

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 and close stack command

Post by Glenn Boyce » Tue May 25, 2010 7:39 am

I notice that with an OpenStack command I have written that it applies to all the substacks as well as the main stack of my application. is there a way to limit it to a specific stack? i.e. either the main stack or one of the substacks.

cheers

Glenn

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: open and close stack command

Post by jmburnod » Tue May 25, 2010 8:57 am

Hi Glenn,

Yes, you can trap the message with an openstack for one or each substack

regards

Jean-Marc
https://alternatic.ch

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

Re: open and close stack command

Post by Glenn Boyce » Tue May 25, 2010 10:00 am

how aout an example?

cheers

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

Re: open and close stack command

Post by Klaus » Tue May 25, 2010 10:16 am

Hi Glenn,

you can:
1. put an empty "dummy" handler in all of your substacks:

Code: Select all

on openstack
  ## 
end openstack

on preopenstack
  ##
end preopenstack
2. Put the "pre-/openstack" handlers of your mainstack into the script of card 1 of your mainstack,
since these messages are also sent to the first card of the stack.

That's what I do all the time, works fine!


Best

Klaus

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: open and close stack command

Post by Dixie » Tue May 25, 2010 1:19 pm

Hey Klaus...

That is a nice work around regarding putting the preOpenStack & openStack handlers on the first card... We live and learn, I never knew that.. but I don't want you taking all the credit as I bet your cat told you about this :D

be well

Dixie

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

Re: open and close stack command

Post by Klaus » Tue May 25, 2010 2:00 pm

Hi Dixie,

well, to be honest, both of my cats told me :D

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

Re: open and close stack command

Post by Glenn Boyce » Wed May 26, 2010 5:27 am

Thanks. I'll give it a try

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

Re: open and close stack command

Post by Glenn Boyce » Fri May 28, 2010 4:02 am

This is getting really frustrating. the other day the following script worked perfectly except that it worked with all the substacks as well. today I get anerror message saying it can't find the stack "apdata" which is located with the stack that has the script but is not a substack.

Code: Select all

on openstack
 put fld "ProductSpecs" of card "productSpecs" of stack "APdata" into fld "productSpecs" of card "Product Specification" of this stack
  put fld "blends" of card "blends" of stack "APdata" into fld "specdata" of card "Compound Specification" of this stack
   
end openstack

kotikoti
Posts: 72
Joined: Tue Apr 15, 2008 7:35 pm

Re: open and close stack command

Post by kotikoti » Fri May 28, 2010 12:48 pm

Hi Glenn,
The operation on openstack may be a bit confusing at times. One thing you need to note is that when you say "stack" in script, it acts upon the current stack, now note that a substack is also a stack hence any refence to make while you at at the substack level but intending to refer to cards in the mainstack, just calling this stack will cause the error. At this level, you would need to reference the card in mainstack accordingly i.e

the card "ABCD" of stack "MAINSTACK NAME"


In my example file, ACME Ltd is the main stack and I have
DEPARTMENT A
DEPARTMENT B

Now, if I mean to operate for all items regardless to where they reside (as in the cards of this stack or a substack of this stack), I can reference them using ACME Ltds script call. In this case, I have

ACME MAIN's openstack script

Code: Select all

on openStack
  --called from the stacks script
  put "123 West of East" into fld "lblAddress"
end openStack
whose effect is as expected, but to show that this only will be possible, I have added a similar openstack on card "ACME MAIN" whose effect on fld "lblAddress" will only be to itself and not the substacks field with a similar name.

To have this call of openstack on card "ACME MAIN" effected the change to say the label on substack DEPARTMENT A, card Transport, just uncomment the line

Code: Select all

--put "1015 Courts Corner Street" into fld "lblAddress" of card "Transport" of stack "DEPARTMENT A"


This leaves the card on substack DEPARTMENT B the only one not altered.

I hope this helps you work out the calls in your script.

kotikoti
ACME Ltd.zip
(1.66 KiB) Downloaded 323 times
Last edited by kotikoti on Fri May 28, 2010 7:26 pm, edited 2 times in total.
Build 160
Version 2.9.0
Platform: Windows

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

Re: open and close stack command

Post by Klaus » Fri May 28, 2010 1:19 pm

Hi Glenn,

if you want to access data from a stack that is NOT currently okpen, you need to supply the filenmae rather than the (short) name of the stack!

Code: Select all

on openstack
  put the effective filename of this stack into tFilename
  set itemdel to "/"
  put "APdata.rev" into item -1 of tFilename
  ## or whatever the FILENAME of that stack is

  put fld "ProductSpecs" of card "productSpecs" of stack tFilename into fld "productSpecs" \
       of card "Product Specification" of this stack
  put fld "blends" of card "blends" of stack tFilename into fld "specdata" of card "Compound Specification" of this stack  
end openstack
Best

Klaus

Post Reply