Looking for best practice in switching libraries
Scott Rossi
scott at tactilemedia.com
Sat Oct 25 12:44:58 EDT 2014
Use ³delete stack xyz².
I¹ve run into similar situations before where closing a stack does not
actually remove it from memory. Delete stack should do it.
Regards,
Scott Rossi
Creative Director
Tactile Media, UX/UI Design
On 10/25/14, 8:45 AM, "Paul Dupuis" <paul at researchware.com> wrote:
>All,
>
>I am looking for a 'best' practice in switching between versions of a
>library stack.
>
>I have several versions of a 3rd party library stack, with file names
>called libraryv1.livecode, libraryv2.livecode, and libraryv3.livecode
>The stack name in the 3 files is always the same - say 'library' and as
>the 3rd party library references itself by name, I can't change the
>stack name - just the file name.
>
>So that means I need to open the library file for the version I want.
>'start using' the library, perform a set of operations, 'stop using' the
>library and close the stack - REMOVING IT FROM MEMORY - so that when I
>open a different version, the stack name does not collide.
>
>The 'close stack' entry in the dictionary correctly notes that you must
>set destroyStack to true to have the stack removed form memory and that
>if the close stack is called from a handle in the stack being close, the
>stack will not be removed form memory until after the handler has
>finished executing. All well an good. The libraries are all external
>stacks.I have code in my main stack:
>
>command closeCurrentLibrary
> global gLibraryStack
> if gLibraryStackis not empty then -- stop using previous library
> stop using "library"
> wait 0 with messages -- allow system to send and process
>releaseStack message
> set the destroyStack of stack "library" to true
> close stack "library" -- allow system to close and remove form memory
> wait 0 with messages
> end if
>end closeCurrentLibrary
>
>command startLibraryv1 -- similar commands for libraryv2 and libraryv3
> global gLibraryStack
> put AppPath()&"libraryv1.livecode" into gLibraryStack
> if there is a file gLibraryStack then
> open invisible stack gLibraryStack
> start using "library"
> else
> put empty into gLibraryStack
> end if
>end startLibraryv1
>
>command useLibraryv1 -- similar commands for libraryv2 and libraryv3
> send "closeCurrentLibrary" to this card in 1 millisec
> wait 5 millisec with messages
> send "startLibraryv1" to this card in 1 millisec
> wait 5 millisec with messages
>end useLibraryv1
>
>So when I use this such as:
>
>useLibraryv1
><do some stuff>
>useLibraryv2 -- generates a message in the IDE "another stack with same
>name do you want to purge" message
><do some other stuff>
>
>I get messages from LiveCode (in the IDE) that the previous library is
>still in memory when I switch libraries and do I want to purge it.
>
>What is the BEST way to close and remove a stack from memory and be sure
>it is really and truly removed?
>
>
>
>
>_______________________________________________
>use-livecode mailing list
>use-livecode at lists.runrev.com
>Please visit this url to subscribe, unsubscribe and manage your
>subscription preferences:
>http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list