' KILL.BAS
' This program lets you delete a file in the current directory.

CLS

PRINT "The current directory contains the following files:"
PRINT

FILES "*.*"                ' display files in current directory

PRINT                      ' get file to delete
INPUT "Which file(s) would you like to delete?  ", filename$

' check for wildcard characters (? and *) in filename$
'   if they exist, print a warning before deleting multiple files
'   if they do not exist, proceed with deletion
'   if the file does not exist, KILL will display a run-time error

IF (INSTR(filename$, "?")) OR (INSTR(filename$, "*")) THEN
    PRINT
    COLOR 4                ' set color to red for effect
    PRINT "Danger:  Wildcards detected that can delete multiple files!"
    COLOR 7                ' set color to default white
    PRINT                  ' prompt for deletion confirmation
    INPUT "Do you want to proceed (Y,N)?  ", reply$
                           ' if reply$ is yes then delete file
    IF (UCASE$(reply$) = "Y") THEN
        KILL filename$
        PRINT
        PRINT UCASE$(filename$); " deleted from system"
    END IF                 ' ...if not then exit program
ELSE
    KILL filename$         ' if no wildcards exist, simply delete file
    PRINT
    PRINT UCASE$(filename$); " deleted from system"
END IF

