[comp.sys.mac.hypercard] Automatic Stack Compaction

daveemme@amdahl.amdahl.com (Dave Emme) (12/23/87)

Here's a handy trick you may not have thought of, to keep your stacks
from growing large because of "garbage".  The following script can
be placed in your Home stack, and will do its work every time you
exit a stack (or exit HyperCard).  It will look at the current size of the
stack and the current amount of free space in it.  If the free space is
more than 20% of the total size of the stack, or in any case, if more
than 10K of the stack is free space, it will automatically compact the
stack for you.

on closeStack
  -- Automatically compact stack if necessary
  get the freeSize of the stack
  put (it div 1024) into free
  get the size of the stack
  put (it div 1024) into total
  get the name of the stack
  put it into stackName
  if free > 9 or free/total > 0.2 then
    put "Compressing the"&&stackName&"... ("&free&"K/"&total&"K)"
    doMenu "Compact Stack"
    put empty into msg
    set the visible of msg to false
  end if
  pass closeStack
end closeStack

-------------------------------------
Dave Emme  (M/S 158)        daveemme@uts.amdahl.com
Amdahl Corporation          {ames,sun,uunet,ihnp4}!uts.amdahl.com!daveemme
1250 E. Arques Ave.
Sunnyvale, CA 94088

    [The opinions expressed above are mine, solely, and do not
     necessarily reflect the opinions or policies of Amdahl Corp.]

-- 

Dave Emme  (M/S 158)        daveemme@uts.amdahl.com
Amdahl Corporation          {ames,sun,uunet,ihnp4}!uts.amdahl.com!daveemme
1250 E. Arques Ave.
Sunnyvale, CA 94088

    [The opinions expressed above are mine, solely, and do not
     necessarily reflect the opinions or policies of Amdahl Corp.]