home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
pocketbk
/
utilsr
/
shell3a
/
RM.OPL
< prev
next >
Wrap
Text File
|
1995-04-17
|
1KB
|
49 lines
PROC rm%:(n%)
Rem
Rem Function to delete a list of files
Rem
LOCAL buf$(128)
LOCAL i%
LOCAL ret%
ONERR ErrTrap::
Rem Test how many arguments (n%) there are. The 1st
Rem argument is the command name so n% must be at least
Rem 2 for there to be any valid arguments.
IF n% < 2
PRINT "Usage: rm <file1> <file2> ..."
RETURN
ENDIF
i%=2
Rem Loop through each of the arguments
WHILE i%<=n%
Rem Test for the escape key
IF KEY=27
GIPRINT ERR$(-114)
BREAK
ENDIF
Rem Parse and get the status of argument i%
ret%=Fparse%:(ADDR(buf$),PEEK$(argv%(i%)))
IF ret%<0
Rem ret% is negative indicating an error.
Rem print this is the form: 'path - error'
ShErr:(i%,ret%)
ELSEIF ret% AND 16
Rem Bit 4 of ret% is set, so this is a directory.
ShErr:(i%,3)
ELSE
TRAP DELETE buf$
IF ERR=-33 Rem No such file, try buf$+"."
TRAP DELETE buf$+"."
ENDIF
IF ERR
ShErr:(i%,ERR)
ENDIF
ENDIF
i%=i%+1
ENDWH
RETURN
ErrTrap::
ONERR off
PRINT err$:(ERR)
ENDP