Close and Delete a stack

Richard Gaskin ambassador at fourthworld.com
Fri Oct 14 12:13:23 EDT 2016


Graham Samuel write:

 > I have a situation where I want to close a stack and then delete it,
 > so that it no  longer exists in memory and so that no naming
 > conflicts occur when I load a fresh stack with the same name. This
 > used to work - part of a script running in a different stack to the
 > one being deleted:
 >
 >   set the cantDelete of stack "myDataStack" to false
 >
 >   set the destroyStack of stack "myDataStack" to true
 >
 >   set the destroyWindow of stack "myDataStack" to true
 >
 >   close stack "myDataStack" -- this should ensure that there are no
 > messages operating in that stack
 >
 >   delete stack "myDataStack" -- this should remove it from memory

Here I can create a new stack, save it, then run:

    delete stack "stackname"

..in the Message Box and the stack both disappears from screen and is 
removed from the Project Browser.

One small bug:  if I then set the stack's destroyStack to true, save it, 
then close it, the Project Browser still lists it until I close and then 
re-open the PB.  That seems a bug.

But as for the script above, if that worked as shown in earlier versions 
it may be that a bug was fixed:

When I set the stack's cantDelete property to true and then try to 
delete it, I get:

    Error with "delete stack "stackname""at line 0: stack locked,
    or object's script is executing

Once I turn off the cantDelete property, the stack can then be deleted 
as expected.

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list