      SUBROUTINE PLW.CLEANUP.SUBS
*PIC-LAN
*
*ALL
*PC
*N
*
*
*
*
      INCLUDE SYS.TYPE.INCLUDE
*
      INCLUDE PL.COMMON
      INCLUDE PL.COMMON.DEFS
      INCLUDE PL.DEFS
      INCLUDE PLIP.COMMON
      INCLUDE PLW.COMMON
*
      OPEN 'VOC'        TO VOC.FD ELSE CALL PLXX.STOP(201,'VOC'       )
      OPEN 'GEN.BP.OUT' TO OBJ.FD ELSE CALL PLXX.STOP(201,'GEN.BP.OUT')
*
      D.COUNTER = 0
      SELECT PL$BASXREF.FD
      EOF = NO
      LOOP
         READNEXT ID ELSE EOF = YES
      UNTIL EOF DO
         READV PG.NM FROM PL$BASXREF.FD , ID , 1 THEN
            READV CUR.NM FROM PL$PGCTRL.FD , PG.NM , 5 THEN
               IF CUR.NM <> ID THEN
                  GOSUB 100
               END
            END
         END
      REPEAT
      D.CNT = D.COUNTER
*
      SELECT VOC.FD
      EOF = NO
      COUNTER = 0
      LOOP
         READNEXT ID ELSE EOF = YES
      UNTIL EOF DO
         IF ID MATCHES 'WEB$1N0N' THEN
            READ X FROM VOC.FD , ID THEN
               IF X<1> = 'V' AND INDEX(X<3>,'GEN.BP.OUT',1) THEN
                  READV DUMMY FROM PL$BASXREF.FD , ID , 1 ELSE
                     GOSUB 100
                  END
               END
            END
         END
         COUNTER = COUNTER + 1
         IF NOT(MOD(COUNTER,50)) THEN PRINT COUNTER : CR :
      REPEAT
*
      IF D.CNT THEN
         PRINT SPACE(26) : D.CNT : ' old subroutines deleted.'
      END
*
      RETURN
*
100   REM Delete sub
*
      IF NOT(D.COUNTER) THEN
         PRINT SPACE(26) : 'Cleaning up old subroutines'
      END
*
      D.COUNTER = D.COUNTER + 1
      PRINT SPACE(21) : D.COUNTER 'R#4' : ' ' : ID
      DELETE VOC.FD , ID
      DELETE OBJ.FD , ID
      DELETE PL$PGBASIC.FD , ID
      DELETE PL$BASXREF.FD , ID
*
      RETURN
   END
