HyperCard: Handlers for Automatic Compacting (8/92)

Whenever you leave a stack that has too much free space, the
initAutoCompact handler (below) will automatically ask if you want to
compact it.

You can tell it to shut up, too. You can adjust the number of free bytes
in a stack that this handler will allow before asking you whether you want
to compact by editing the field to the right.

on initAutoCompact
global autoCompactEnabled,maxFreeSizeOfStack
put true into autoCompactEnabled
lock screen
push card
go to card "AutoCompact" of stack "Cookbook Reference"
if the result is empty -- card exists
then put card field "MaxFreeSizeOfStack" into maxFreeSizeOfStack
else put 25000 into maxFreeSizeOfStack
pop card
unlock screen
end initAutoCompact

on autoCompact
-- Automatic stack compaction that can stop asking
-- Whenever you leave a stack that has too much free space,
-- this handler will automatically ask if you want to compact it.
-- You can tell it to shut up, too.

global autoCompactEnabled,maxFreeSizeOfStack
if autoCompactEnabled is not true then exit autoCompact
get the freeSize of this stack
if it > maxFreeSizeOfStack then
put "Compact this stack? (" & it div 1024 & "K free)" into prompt
answer prompt with "Yes" or "No" or "Stop Asking"
if it is "Stop Asking" then put false into autoCompactEnabled
if it is not "Yes" then exit autoCompact
doMenu "Compact Stack"
end if
end autoCompact


This article is adapted from the Claris Tech Info database.
Published Date: Feb 19, 2012