REALLY close stack

Scott Rossi scott at tactilemedia.com
Tue Jun 15 17:58:19 EDT 2004


Recently, "Troy Rollins"  wrote:

> I have a stack which references a number of external stack files as
> resources. Only one of these resources can be "active" at a time. The
> user can create these resource stacks, and name them whatever they
> want... but they all have the same "internal" stack name.  When my
> program starts, it looks through the resource directory, loads them one
> by one, extracts enough information to reload the file as the "main
> resource" when requested by selecting it from a list of available
> resources.
> 
> The problem? You probably guessed it. Rev won't purge the first file,
> and always complains that there is already a stack open with that name.
> 
> In my repeat loop which reads the files I "repeatedly" try to kill the
> darn thing, but they are very persistent. It looks something like this
> -
> _________________________________________________________
> repeat for each line tFile in tFileList
>    if there is a stack "Current Resource" then
>      set the destroyStack of stack "Current Resource" to TRUE
>      close stack "Current Resource"
>    end if
> 
>      go invisible stack URL (the defaultFolder & "/" & tFile)
>      if there is a field "NameField" of stack "Current Resource" then
> 
>        Put tFile & TAB & field "NameField" of stack "Current Resource"
> after field "Resource Select List" of card "Main Interface" of stack
> "The Program"
>      end if
> 
>    set the destroyStack of stack "Current Player" to TRUE
>    close stack "Current Player"
> 
>  end repeat
> ________________________________________________________
> 
> In other words, I try to kill the bugger twice, but no go. Is there a
> "best way" to use and kill a stack, so that another which has the same
> stack name can be used without error messages?

Is there a reason why you're not saving your stack files with their
destroyStack property set to true?  I work this way with all my own stacks
(if I want a stack to stay in memory I hide it, and closing the stack should
remove it). You might be able to remove the problem you encountered and
eliminate portions of the above script by setting destroyStack to true.

Regards,

Scott Rossi
Creative Director
Tactile Media, Multimedia & Design
-----
E: scott at tactilemedia.com
W: http://www.tactilemedia.com



More information about the use-livecode mailing list