home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / pocketbk / utilsr / shell3a / RM.OPL < prev    next >
Text File  |  1995-04-17  |  1KB  |  49 lines

  1. PROC rm%:(n%)
  2. Rem
  3. Rem Function to delete a list of files
  4. Rem
  5. LOCAL buf$(128)
  6. LOCAL i%
  7. LOCAL ret%
  8.     ONERR ErrTrap::
  9.     Rem Test how many arguments (n%) there are. The 1st
  10.     Rem argument is the command name so n% must be at least
  11.     Rem 2 for there to be any valid arguments.
  12.     IF n% < 2
  13.         PRINT "Usage: rm <file1> <file2> ..."
  14.         RETURN
  15.     ENDIF
  16.     i%=2
  17.     Rem Loop through each of the arguments
  18.     WHILE i%<=n%    
  19.         Rem Test for the escape key
  20.         IF KEY=27
  21.             GIPRINT ERR$(-114)
  22.             BREAK
  23.         ENDIF
  24.         Rem Parse and get the status of argument i%
  25.         ret%=Fparse%:(ADDR(buf$),PEEK$(argv%(i%)))
  26.         IF ret%<0
  27.             Rem ret% is negative indicating an error. 
  28.             Rem print this is the form: 'path - error'
  29.             ShErr:(i%,ret%)
  30.         ELSEIF ret% AND 16
  31.             Rem Bit 4 of ret% is set, so this is a directory.
  32.             ShErr:(i%,3)
  33.         ELSE
  34.             TRAP DELETE buf$
  35.             IF ERR=-33    Rem No such file, try buf$+"."
  36.                 TRAP DELETE buf$+"."
  37.             ENDIF
  38.             IF ERR
  39.                 ShErr:(i%,ERR)
  40.             ENDIF
  41.         ENDIF
  42.         i%=i%+1
  43.     ENDWH
  44.     RETURN
  45. ErrTrap::
  46.     ONERR off
  47.     PRINT err$:(ERR)
  48. ENDP
  49.