I believe there is a IDE handler you can call to unload a stack -
something like "revUnloadStack" or similar, but I do not recall the
exact API name.
Hopefully, some one else on the list has the exact API details.
Alternatively, contact supp...@livecode.com and ask what the IDE API is
to unload a stack.
On 4/4/2023 10:22 AM, Håkan Liljegren via use-livecode wrote:
When my students turn in their assignments all their individual stacks usually
have the same name. If I try to loop through all of them there seems to be no
way to close one stack and move on to the next one (with the same name) without
getting the dialog asking if I want to save, purge or cancel the previous
stack?!
I have tried to:
close stack tStack
delete stack tStack
That didn't work
I then thought that it might be that the IDE needed some more time to clean up
so I added a loop:
delete stack tStack
repeat while tStack is among the lines of the openStacks
wait for 100 milliseconds with messages
end repeat
That didn’t work either as the next time I try to open a stack with the same
name I get the dialog again
I then thought that maybe the handler needs to be finished before the cleanup
is done so I tried to rewrite using a system where I added all files that
should be crawled into a local variable and added the current stack into
another and created a system using the send command:
local sFileList # A text with one file path per line for all files
that should be crawled
local sCurrentStack # The name of the currently crawled stack
on stackCrawl
if sCurrentStack is among the lines of the openstacks then
send “stackCrawl” to me in 500 milliseconds
else if sCurrentStack is not empty then
# Now we now that the sCurrentStack is not among the open stacks (I.e
closed and deleted)
put empty into sCurrentStack
if sFileList is empty then
# All stacks crawled => We are finished!
else
send “stackCrawl” to me in 0 milliseconds
end if
else # sCurrentStack is empty so we should move on to the next stack in the
file list!
put line 1 of sFileList into tFile
delete line 1 of sFileList
put the openStacks into tStackList
open stack tFile
repeat for each line aStack in the openStacks
if aStack is not among the lines of tStackList then
put aStack into sCurrentStack
exit repeat
end if
end repeat
# Do needed operations on sCurrentStack
delete sCurrentStack
send “stackCrawl” to me in 500 milliseconds
end if
end stackCrawl
This also gives the same result. Then I realised that the stacks I have also have sub stacks so I also tried:
put the substacks of stack sCurrentStack into tSubStacks
lock messages
repeat for each line tSubStack in tSubstacks
close stack tSubStack
end repeat
delete stack sCurrentStack
unlock messages
I even found a call to revIDEHandleObjectDeleted by peeking into the IDE
itself. Added a call to that function but still no luck!
Even if I loop through all my stacks (by clicking purge for each stack) and then do
a "put the openStacks” I can see that the last stack is not among the the open
stacks. But, if I now try to open the first stack in the list again I still get a
dialog asking me about what I want to do with the last stack in the list (save,
purge or cancel)!
So as soon as a stack I opened via script there is no way to close it via
script and also remove it from the internal workings of the IDE. Is there ANY
way to really delete the stack from the IDE memory so I can open a stack with
the same name without a dialog popping up?!
I’ve reported this as a bug
(https://quality.livecode.com/show_bug.cgi?id=24163), but is still interested
if anyone has at least a workaround…
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode