Compressing an entire stack
    Shari 
    shari at gypsyware.com
       
    Fri Mar 11 08:43:22 EST 2005
    
    
  
My many many thanks to Brian Yennie and Richard Gaskin for their 
posts last year and the year before about stack compression.  I've 
developed a need for it and boy is it going to be a lifesaver!  The 
code I ended up using uses three stacks:
stackToShrink - the original, bloated stack
storageStack - the stack that holds the compressed data from the 
bloated stack (this stack gets distributed with the program)
userStack - the stack gets uncompressed when the user opens the 
program and saved into a permanent stack on their drive
To shrink:
   put url ("binfile:" & stackToShrink) into s
   set the stackData of stack storageStack to compress(s)
   save stack storageStack
To open:
   if there is not a stack userStack then
     put decompress(the stackData of stack storageStack) into s
     set the fileType to "xxxxMSTK" # xxxx is changed to whatever the 
creator code for the program is
     set the stackFileType to "xxxxMSTK" # wasn't sure if both types 
were needed so used both
     put s into url ("binfile:" & userStack)
     save stack userStack
   end if
To use:
   start using userStack # this stack never gets seen, it just holds data
I tried to use the following but couldn't get it to work:
set the stackData of storageStack to compress(stack stackToShrink)
You guys are dreamboats for sharing this info.  It has become 
important to me to shrink the stack size where possible.
Shari
-- 
Mac and Windows shareware games
http://www.gypsyware.com
    
    
More information about the metacard
mailing list