      SUBROUTINE PLZ.CLEANUP.SUB
*PIC-LAN
*
*ALL
*PC
*N
*
*
*
*
******************************************************************************
******************************************************************************
***                                                                        ***
*** (C) Copyright 1990-2005 Doug Dumitru, All Rights Reserved.             ***
***                                                                        ***
*** This program is licensed under the terms of the GNU General Public     ***
*** License, version 2.0 with attached notices.                            ***
***                                                                        ***
*** The full text can be found in the LICENSE.TXT file in the              ***
*** PLIP.BP database file (the /usr/qmweb/PLIP.BP/PLIP.BP directory).      ***
***                                                                        ***
******************************************************************************
******************************************************************************
*
      INCLUDE SYS.TYPE.INCLUDE
*
      INCLUDE PL.COMMON
      INCLUDE PL.COMMON.DEFS
      INCLUDE PL.DEFS
      INCLUDE PLIP.COMMON
      INCLUDE PLW.COMMON
*
      
      NW = PL_NOW()
*
      READU NW0 FROM PL$CTRL.FD , 'APP.CLEANUP' LOCKED
         RETURN
      END ELSE
         NW0 = 0
      END
*
*$*   PL_READU NW0 FROM PL$CTRL.FD , 'APP.CLEANUP' ELSE NW0 = 0
*
      IF ( ( NW - NW0 ) < 0 ) OR ( ( NW - NW0 ) > 3600 ) ELSE
         RELEASE PL$CTRL.FD , 'APP.CLEANUP'
         RETURN
      END
*
      SELECT PL$APP.FD
      EOF = NO
      LST = ''
      LOOP
         READNEXT ID ELSE EOF = YES
      UNTIL EOF DO
         IF NOT(INDEX(ID,'*',1)) THEN
            READV TM FROM PL$APP.FD , ID , 2 THEN
               IF TM < NW THEN
                  LST<-1> = ID
               END
            END
         END
      REPEAT
*
      SELECT PL$APP.FD
      EOF = NO
      LOOP
         READNEXT ID ELSE EOF = YES
      UNTIL EOF DO
         L.ID = FIELD(FIELD(ID,'*',1),'.',1)
         LOCATE(L.ID,LST;DUMMY) THEN
            DELETE PL$APP.FD , ID
         END
      REPEAT
*
      WRITE PL_NOW() ON PL$CTRL.FD , 'APP.CLEANUP'
*
      RETURN
   END
