/***************************************************************************/
/* Optimize.rexx   ©1993 Stu Churchill   2:250/107.97@fidonet              */
/*                                                                         */
/* $VER: Optimize.rexx 1.50 (17.9.93)                                      */
/*                                                                         */
/* Call this script from your cron every morning to perform a daily        */
/* optimization of your messagebase                                        */
/***************************************************************************/

options results

spot_path = 'Workbench:WBStartup/Spot CONFIGPATH "MAIL:Configs/Spot/"'

if ~show('ports','SPOT') then do
  address command 'run 'spot_path
  'WaitForPort SPOT'
  quit = yes                  /* Marker to close SPOT after finishing */
end

address 'SPOT'
'isiconified'
if rc = 0 then do
  icon = yes                  /* Marker to re-iconify after finishing */
  'uniconify'
end
'spot2front'
'isarealist'
if rc = 5 then do
  'arealist'
end
'purgebuffers'                /* Free up as much memory as possible */
'optimize NOREQ CLOSEWIN'     /* Perform optimization */

if quit = yes then do
  'quitspot NOREQ'            /* Close SPOT if we had to open it ourselves */
  exit
end
if icon = yes then do
  'iconify NOREQ'             /* Re-iconify if necessary */
end

exit
