* MVNET.HOUSEKEEPALL.ACCOUNTS
* Copyright 2006 Nebula Research and Development
* This code may be freely used and modified without permission
* but shall not be sold. Please leave these comments intact
* and report issues to Nebula R&D.
*
* For use with mv.NET over D3
* Description: Clean up all mv.NET temp files in a D3 system.
* mv.NET cleans up after itself with a housekeeping process,
* but only if it’s running pooled sessions and housekeeping
* is turned on. This wipes all temp files in accounts that
* may not be pooled.
*
* History:
* Written: 2006sep02 Tony Gravagno, Nebula R&D
*
* First, housekeep current account
  WIPE.CMD = \MVNET.HOUSEKEEPALL\:@AM:\YES\
  EXECUTE WIPE.CMD CAPTURING OUT
* Now go and steal tmp files from all other accounts
  ACCTS.CMD = \SSELECT MDS,, WITH A1 D] Q]\
* Get a list of accounts
  EXECUTE ACCTS.CMD RTNLIST ACCTS
  EOF.ACCTS = 0
  LOOP
    * Get the next account
    READNEXT ACCT FROM ACCTS ELSE EOF.ACCTS = 1
  UNTIL EOF.ACCTS DO
    FILES.CMD = \SSELECT \:ACCT:\,, = MVNET.TMP_]\
    * Following assumes we have retrieval access to the MD
    EXECUTE FILES.CMD RTNLIST FILES CAPTURING OUT
    IF FILES # "" THEN
      CRT "CLEARING ":ACCT
      CT = DCOUNT(FILES,@AM)
      FOR FNUM = 1 TO CT
        EXECUTE \STEAL-FILE \:FILES<FNUM>:@VM:ACCT CAPTURING OUT
      NEXT FNUM
      * All files from that account are now in this account
      EXECUTE WIPE.CMD CAPTURING OUT
    END
  REPEAT