Completely purging a stack from memory when closed....

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

AndyP
Posts: 634
Joined: Wed Aug 27, 2008 12:57 pm
Contact:

Re: Completely purging a stack from memory when closed....

Post by AndyP » Thu Feb 26, 2015 8:19 am

Hi Justin,

This is what I use in my projects.
No need to keep a list of the stacks you need to close.

on QuitMyProject
lock messages
-- stop using stacks
put the stacksInUse into myStacks
repeat for each line myStack in myStacks
stop using stack myStack
end repeat
-- stacks
put the openStacks into myStacks
put "message box,home,tool,Message Box,revTools,revMenubar" & comma & the short name of me into myDontClose
repeat for each line myStack in myStacks
if myStack is not among the items of myDontClose then close stack myStack
end repeat
-- messages
put the pendingmessages into myMsgs
repeat for each line myMsg in myMsgs
cancel item 1 of myMsg
end repeat
set the backdrop to none
close me
if the environment is not "development" then
quit
end if
end QuitMyProject
Andy .... LC CLASSIC ROCKS!

JustinW42
Posts: 52
Joined: Sun Nov 30, 2014 7:22 am
Contact:

Re: Completely purging a stack from memory when closed....

Post by JustinW42 » Thu Feb 26, 2015 8:37 am

Great tip! Thanks, Andy!
-------------------------------------------------------------------------------------------------------------
Some things I do: http://www.katanadtg.com --- http://www.dtgprintsolutions.com

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Completely purging a stack from memory when closed....

Post by jacque » Thu Feb 26, 2015 11:01 pm

And if you only want to close substacks, you don't even need the list of stacks to exclude. You can just do this:

Code: Select all

repeat for each line myStack in the substacks of this stack -- assumes the script is in the mainstack
  close stack myStack
end repeat
This only works with substacks, not with separate stacks that aren't part of the main stackfile. Andy's works with all open stacks, regardless of their origin.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

JustinW42
Posts: 52
Joined: Sun Nov 30, 2014 7:22 am
Contact:

Re: Completely purging a stack from memory when closed....

Post by JustinW42 » Fri Feb 27, 2015 6:49 am

Would Andy's version close stacks that are open outside of the current program? ie, if I am running two different programs created in LC, would it close both of them if I executed the script from only one? I am not advanced enough to be using outside stacks in any of my programs, but I am getting close to that point...... I made an order management program to monitor all of the designs that come through our system, and it would be cool if I could select a design and then click "LOAD IN DESIGN LAB" to have the main Design Lab program open up and automatically load the design that was selected in the management program..... Of course, that is a thread for another day. haha
-------------------------------------------------------------------------------------------------------------
Some things I do: http://www.katanadtg.com --- http://www.dtgprintsolutions.com

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

Re: Completely purging a stack from memory when closed....

Post by Klaus » Fri Feb 27, 2015 1:57 pm

Hi Justin,

please define "the current program"?
Do you mean different standalones?

If the latter, then every standalone lives in its own "world" and will of course only handle
its own "components" (= substacks) and docs that had been opened by that namely standalone.
So the answer to this question:
Would Andy's version close stacks that are open outside of the current program?
is NO!
it would be cool if I could select a design and then click "LOAD IN DESIGN LAB" to have the main Design Lab program open up and automatically load the design that was selected in the management program..
Check "launch DOCUMENT with APPLICATION" in the dictionary!


Best

Klaus

JustinW42
Posts: 52
Joined: Sun Nov 30, 2014 7:22 am
Contact:

Re: Completely purging a stack from memory when closed....

Post by JustinW42 » Sun Mar 01, 2015 7:46 am

Thanks Klaus! You are correct - I was asking what would happen if I had two distinctly different standalone applications running when the command is executed. That clarifies things for me!

I will look into that "launch DOCUMENT with APPLICATION" function!
-------------------------------------------------------------------------------------------------------------
Some things I do: http://www.katanadtg.com --- http://www.dtgprintsolutions.com

JustinW42
Posts: 52
Joined: Sun Nov 30, 2014 7:22 am
Contact:

Re: Completely purging a stack from memory when closed....

Post by JustinW42 » Sun Mar 01, 2015 10:42 am

It appears as though the "launch DOCUMENT with APPLICATION" function would open a pre-existing (ie, complete / finished) document using the specified program...... What I am trying to accomplish would be selecting a Design from one program, then opening it in another LC program I created to edit a design. Each design has a lot of information associated with it on the server (in a MySQL database), so I would need to load all the information for the design in the Design Lab when it is forced to open, to properly display the design.

The caveat here is that a "design" is simply a collection of information stored on the server (DB info for displaying all of the design elements properly, as well as associated image assets for the selected design), rather than an actual single file stored on the local system.

In the next day or so I will create a new thread to address this issue, since I feel as though it might take some careful thought to execute as I have envisioned... In the meantime, I will continue researching the Launch command to see if I am missing anything that might help.
-------------------------------------------------------------------------------------------------------------
Some things I do: http://www.katanadtg.com --- http://www.dtgprintsolutions.com

Post Reply