Force the script editor to update?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Force the script editor to update?
I think I found a clue: if the main stack to be closed has its cantDelete property set to true, the delete stack command gets stuck.
Is this a bug due to the double meaning of delete stack?
Is this a bug due to the double meaning of delete stack?
Re: Force the script editor to update?
After several tests, the following script to close and remove a target stack from memory seems to work.
It has to be called from another stack (otherwise, use the File menu article Close and Remove from Memory).
The delete stack command works very cleanly: the main stack and its substacks are closed, removed from the Message Path if necessary, and Script Editor and Project Browser are updated.
It has to be called from another stack (otherwise, use the File menu article Close and Remove from Memory).
The delete stack command works very cleanly: the main stack and its substacks are closed, removed from the Message Path if necessary, and Script Editor and Project Browser are updated.
Code: Select all
on stackCloseAndRemove pStackShortName, pSilentFailBoolean // short name of the stack to close
// the stack to close will not be saved
if (pStackShortName <> the short name of this stack) then // can't be called from the stack to close
if (there is a stack pStackShortName) then
try
if (the mainStack of stack pStackShortName = pStackShortName) then
set the cantDelete of stack pStackShortName to false
delete stack pStackShortName
else close stack pStackShortName // it's a substack: do not "delete" !
catch errMsg
if (not pSilentFailBoolean) then
answer error "Unable to close and remove from memory stack '" & pStackShortName & "':" & cr & cr & \
errMsg with "Cancel" or "Close"
if (it = "Close") then close stack pStackShortName // simple close
end if
end try
else answer error "There is no stack '" & pStackShortName & "'." with "Cancel"
else close me // simple close if this command is called from the stack to close
end stackCloseAndRemove
-
- Livecode Opensource Backer
- Posts: 9444
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Force the script editor to update?
Maybe you could make a stack that loads with LC as a palette that has a scrolling list of all open stacks and a button to delete a selected stack.
Re: Force the script editor to update?
Yes, I have that. It is precisely for my development palette that I needed this kind of script.richmond62 wrote: ↑Sat Apr 27, 2024 9:10 amMaybe you could make a stack that loads with LC as a palette that has a scrolling list of all open stacks and a button to delete a selected stack.
-
- VIP Livecode Opensource Backer
- Posts: 7257
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Force the script editor to update?
Good catch, that would be it. The cantDelete property comes from HyperCard and has been around for decades. It isn't a bug, and technically the other instances of delete aren't either. It was mainly intended to be used for controls to avoid accidentally deleting them, and since HC automatically saved the stack after every card change it was necessary to avoid losing things permanently without warning. Now that we have manual saves it isn't as necessary. I can't remember ever needing to use it on stacks though. Is there a reason you need it?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Force the script editor to update?
Thank you Jacqueline for these explanations.
I have just done a test: a stack script is able to delete all its cards and we end up with a stack without a card - which was nonsense for HC.
In any case, everything works fine now.
I suppose not. Normally, the cantDelete of my stacks is false but when a stack has a variable number of cards and the user can easily delete cards, I feared that the user would delete all the cards and therefore delete the stack - this is an old habit of HC user!
I have just done a test: a stack script is able to delete all its cards and we end up with a stack without a card - which was nonsense for HC.
In any case, everything works fine now.