! +-------------------------------------------------------------------------+
! |Program to read a directory of .LST files on an account and determine    |
! |if a .T, .TXT or .WRT file exists with the same name. If it does then    |
! |the .LST file is deleted.                                                |
! |                                                                         |
! |The directory file is created with the command:                          |
! |                 DIR CLEANT.DAT=ALL:*.*[]/D/K.                           |
! |                                                                         |
! |The entire process of creating the directory file and running CLEANT     |
! |can be automatically started by typing CLEANT while at the dot (.).      |
! +-------------------------------------------------------------------------+
!
! Copyright (C) 1986 by Seattle Technology, Inc.
!                       2000 124th Avenue NE
!                       Suite B-109
!                       Bellevue, WA   98005
!                       (206) 455-5701
!
! NOTICE: This program may be freely distributed to AMUS members only,
!         courtesy of Seattle Technology, Inc.  Sale or other use of this
!         program for profit is strictly forbidden by Seattle Technology, Inc.
!         who retains ownership rights.  Use of this program is subject to
!         the user leaving the Copyright message screen display intact.
!
map1 D'STRING,S,80
map1 D'STRING2,S,80
map1 X,F
map1 Z,F
map1 Z1,F
map1 Z2,F
map1 Z3,F
map1 SIZE,F
map1 BLKS'FREED,F,6,0
map1 CR,S,1,""

!
!NOTICE: The following Copyright message must displayed on the screen
!
!
!
       print tab(-1,0); TAB(3,18); "CLEANT -- File Cleanup Program"
       print            tab(5,18); "      Copyright (C) 1986"
       print            tab(7,18); "   Seattle Technology, Inc."
       print tab(9,11); "Provided Courtesy of the AMUS Bulletin Board"

       print
       print
       print "Enter a <CR> to continue";
       input CR

       lookup "CLEANT.DAT", X
       if (X = 0) then &
               print "?CLEANT.DAT not found" :&
               goto FINI

       open #1, "CLEANT.DAT", input

NXT'FILE:
       input line #1, D'STRING
       if (eof(1) = 1) then goto FINI
!
! Be sure .LST file still exists
!
       lookup D'STRING, SIZE
       if (SIZE = 0) then &
               print "?.LST file not found: ";D'STRING :&
               goto NXT'FILE

       if (SIZE < 0) then &
               print "?.LST file is not sequential: ";D'STRING :&
               goto NXT'FILE

       X = instr(1,D'STRING,".")
       if (X = 0) then &
               print "?Invalid Filespec: ";D'STRING :&
               goto NXT'FILE
!
! look for .T file
!
       D'STRING2 = D'STRING[1;X] + "T" + D'STRING[X+4;len(D'STRING)]
       lookup D'STRING2, Z1
       if (Z1 < 0) then Z1 = 0         ! ignore random files
!
! look for .TXT file
!
       D'STRING2 = D'STRING[1;X] + "TXT" + D'STRING[X+4;len(D'STRING)]
       lookup D'STRING2, Z2
       if (Z2 < 0) then Z2 = 0         ! ignore random files
!
! look for .WRT file
!
       D'STRING2 = D'STRING[1;X] + "WRT" + D'STRING[X+4;len(D'STRING)]
       lookup D'STRING2, Z3
       if (Z3 < 0) then Z3 = 0         ! ignore random files

       Z = Z1 + Z2 + Z3

       if (Z > 0) then &
         print D'STRING;" -- Deleted" :&
         kill D'STRING :&
         BLKS'FREED = BLKS'FREED + SIZE &
       else &
         print D'STRING;" -- Bypassed"

       goto NXT'FILE

FINI:
       if (eof(1) >= 0) then close #1
       print ""
       print "Total blocks freed by CLEANT is";BLKS'FREED
       print ""
       end