Cannot really purge

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Cannot really purge

Post by dunbarx » Wed Mar 07, 2018 12:38 am

I am working on a series of instances of a stack. They live in different stack files, but have the same name. All of them have their destroyStack and destroyWindow set to "true".

But when I close one to play with one of its close relatives, I always have to dismiss the dialog that tells me that a stack of the same name is already open, and that I should purge the one I just closed.

i always do, but I wish I did not have to.

Also, when making a standalone, I always get the same dialog along the way.

So how does one really, truly knock a stack out of memory when closing it? I know quitting LC and re-opening is one way.

Craig

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Cannot really purge

Post by bogs » Wed Mar 07, 2018 3:00 am

When you close it, are you hitting 'close and remove from memory', or just clicking the [x] (or close on the window) to close it?

If your in the IDE, the only way I know that is supposed to work is 'close and remove from memory'. In a standalone, then the destroy stack setting should do it.
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Cannot really purge

Post by dunbarx » Wed Mar 07, 2018 3:53 am

Bogs.

Aha. I had no idea what you were talking about until I looked in the "File" menubar. I rarely look in any menubar.

Anyway, I guess that is the answer, eh? But is there no way to invoke that menuItem? HC had its beloved "doMenu" command, something I sorely miss.

I am not even sure how to fake that with a plug-in. This ;

Code: Select all

on mouseUp
   domenu "close and remove from memory" --does nothing
   doMenu "close and remove from memory" of menu "file" --throws an error
end mouseUp
Craig

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Cannot really purge

Post by bogs » Wed Mar 07, 2018 5:17 am

Well, you can actually reach that 'close and remove from memory' in a number of ways in the IDE, the File menu as you found, or right clicking on the stack in either the Project or application browser.

As I might have mentioned before, I (am) learning this language in a fragmentary way, not my preferred way, which would be a manual similar to the one that came with Hc itself ( I read a great deal of it and it triggered fond memories of my old IBM manuals, which I still have :wink: but of course a lot of it is full of rabbit holes applied to Lc)

Hopefully someone with more familiarity with it will chime in at some point, unfortunately, I don't have a good answer :cry:

As of at least 6.x, the code for that menu item ran like this -

Code: Select all

case "Close and Remove From Memory"
         if the mode of the topStack is not 1 then exit menuPick
         put revBeforeRemovingStackFromMemory(the short name of the topStack) into tCheck
         if tCheck is not empty then
            answer error "Before Revolution can remove this stack from memory please:" & cr & cr & tCheck as sheet
            exit menuPick
         end if
         
         set the defaultStack to the topStack
         
         local tStackPath, tStackID
         put the effective fileName of this stack into tStackPath
         if tStackPath is empty then put the mainStack of this stack into tStackpath
         
         local tMainstack
         put the mainStack of stack tStackPath into tMainstack
         
         local tSubstacks
         put the subStacks of stack tStackPath into tSubstacks
         
         local tStacks
         put tMainStack & cr & tSubstacks into tStacks
         answer warning "Really remove the stack file" && tStackPath && "from memory?" & cr & "Any changes made since saving will be lost from the following stacks:" & cr & cr & tStacks with "Cancel" or "OK" as sheet
         if it is "Cancel" then 
            exit menuPick
         end if
         
         put  the long id of stack tMainStack into tStackID
         
         # OK-2008-08-18: Bug 6932 - Update the script editor here as messages is locked when deleting the stack
         revIDEHandleObjectDeleted the long id of stack tMainStack
         
         lock messages -- prevent user stack saving during the close, erasing substacks
         repeat for each line tSubStack in tSubstacks
            close stack tSubStack
         end repeat
         delete stack tMainStack
         unlock messages
         
         if the mode of stack "revApplicationOverview" is not 0 then
            send "revRefreshTree" to stack "revApplicationOverview"
         end if
         
         send "refreshBrowser" to stack "revProjectBrowser" in 0 milliseconds
         break
Now, you have been at this much MUCH longer than I, so maybe you can solve it ? I'm sure you follow it better than I do at any rate, I get the gist of it only at this point :D so I usually right click in the PB and choose it there.
Image

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Cannot really purge

Post by bogs » Wed Mar 07, 2018 5:37 am

While poking around the dictionary, I did find one bit that might work for a plugin,

Code: Select all

select menuItem 6 of menu "File"
You would have to poke around to figure out which is the correct menuItem, in this case [6] opened up a recent project I was working on :P

*Edit - took a few guesses, but I found it after all, at least as of Lc 6.5.2.

Code: Select all

on mouseUp
   select menuItem 37 of menu "File"
end mouseUp
*Edit 2 - in 8.1.6 the actual line is

Code: Select all

select menuItem 40 of menu "File"
which you can execute from the message box. I think I'd stick with right clicking it though, really what are you saving doing it this way?
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7230
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Cannot really purge

Post by jacque » Wed Mar 07, 2018 5:36 pm

With both destroystack and destroywindow set, it should purge itself. The IDE must be holding on to something. I usually just use either the contextual menu to remove the stack from memory or the message box. The command you need is "delete this stack".

Don't worry, it doesn't delete the file, just the copy in RAM.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Cannot really purge

Post by bogs » Wed Mar 07, 2018 6:01 pm

bogs wrote:
Wed Mar 07, 2018 5:17 am
Hopefully someone with more familiarity with it will chime in at some point, unfortunately, I don't have a good answer
I clicked my heels 72 times last night, and this morning my hopes were answered!
jacque wrote:
Wed Mar 07, 2018 5:36 pm
The command you need is "delete this stack".
Thank you Jacque! :mrgreen:
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Cannot really purge

Post by dunbarx » Wed Mar 07, 2018 6:01 pm

@Jacque.
The IDE must be holding on to something
Hmmm? Cannot my IDE just let it go and move on?

@Bogs.

I will try your idea when I get back to my office. This can be exploited with a plug-in, but, as per Jacque above, not sure why I have to.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9375
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Cannot really purge

Post by richmond62 » Wed Mar 07, 2018 6:32 pm

"doMenu" command, something I sorely miss
Why?
doMenu.png
purge.png
purge.png (41.69 KiB) Viewed 6392 times

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7230
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Cannot really purge

Post by jacque » Wed Mar 07, 2018 6:35 pm

The IDE does some complicated things under the hood and needs to clear all the references it keeps, which is what the menu item does. Using delete from the message box is kind of like throwing a bomb at the stack but I haven't seen anything bad happen. I do it all the time.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Cannot really purge

Post by bogs » Wed Mar 07, 2018 7:36 pm

dunbarx wrote:
Wed Mar 07, 2018 6:01 pm
@Bogs.
I will try your idea when I get back to my office. This can be exploited with a plug-in, but, as per Jacque above, not sure why I have to.
Jacque and I are holding hands on that one, I'm not sure why you'd have to either. We also agree (I think) that right clicking in either the AB or PB on the stack, then choosing close and remove is the far easier/better way to go.

Ultimately, though, her bomb throwing technique would sure work as well, and sounds much cooler :twisted:
Image

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Cannot really purge

Post by bogs » Wed Mar 07, 2018 7:40 pm

richmond62 wrote:
Wed Mar 07, 2018 6:32 pm
"doMenu" command, something I sorely miss
Why?
doMenu.png
purge.png
Because if you go a bit further down to the comments, you see this -
Comments:
The doMenu command is not implemented for all menu items. This command is included in LiveCode for compatibility with imported HyperCard stacks.
When you try to use it for the 'close and remove' menu item, it errors out with can't find handler, obviously this is one of those that is not implemented
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9375
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Cannot really purge

Post by richmond62 » Wed Mar 07, 2018 8:06 pm

this is one of those that is not implemented
Blast!

But wait . . . IF the menu item is a pulldown menu one could try this:

send "menuPick Close and Remove From Memor&y" to btn "File" of stack "revMenubar"

[Don't ask me why 'someone' decided to slip an ampersand into the word "Memory"]

B*gger: just tried it, and cannot get that to work.

Probably
because "Close and Remove From Memor&y" is NOT one word.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Cannot really purge

Post by bogs » Wed Mar 07, 2018 8:35 pm

The ampersand is to denote the key control, typical for most higher level languages. Like when you see "E&xit" :)
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9375
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Cannot really purge

Post by richmond62 » Wed Mar 07, 2018 8:38 pm

&&&&&& Thank you 8)

Why won't a send "menuPick" work?

Post Reply

Return to “Talking LiveCode”