How to loop through stacks with same name?

J. Landman Gay jacque at hyperactivesw.com
Wed Apr 5 00:42:59 EDT 2023


Are you opening all the same-named stacks at once? LC warns that this 
produces unreliable results and should be avoided. The "delete stack" 
command does work from a script, but if there are several open with the 
same name there's no telling what the engine will do. The normal way to 
handle this is to only open one, delete it when done with it, and then open 
the next.

But if it is necessary for some reason to have multiple same-named stacks 
open then check the mainstacks rather than the openstacks. The mainstacks 
function should report all stacks in memory, not just the ones that are 
open on screen.

Untested, but try this:

repeat until "stackName" is not in the mainstacks -- whatever the duplicate 
stack name is
 delete stack "stackName"
end repeat

It might work. Also, check your LC preferences in the Files and Memory 
pane. Tick the option to close the stack even if its deleteStack property 
is false. That should allow you to close any stack and remove it from 
memory just with the close box.

 --
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On April 4, 2023 9:25:08 AM Håkan Liljegren via use-livecode 
<use-livecode at lists.runrev.com> 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?!






More information about the use-livecode mailing list