qb45advr.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
KILL Statement Programming Example
  QuickSCREEN      Details     Example      Contents      Index
──────────────────────────────────────────────────────────────────────────────
KILL Statement Programming Examples
 
These examples show how to use KILL to delete files.
 
Example 1
 
Here is an example of using wild-card characters with KILL.
This example will not run unless the specified files are found:
 
KILL "DATA1?.DAT"     'Kills any file with a six-character
                      'base name starting with DATA1 and
                      'also with the extension .DAT.
 
KILL "DATA1.*"        'Kills any file with the base name
                      'DATA1 and any extension.
 
KILL "GREG*.DAT"    'Kills any file with the extension
                      '.DAT in a subdirectory called GREG.
 
Example 2
 
Here is an example program that deletes the file specified on
the command line:
 
' Make sure you have selected Full Menus from the Options menu,
' then select Modify COMMAND$ from the Run menu to specify a file.
' Specify any file, but be sure it's one you want to delete.
DEFINT A-Z
CLS    ' Clear screen
ON ERROR GOTO Errorhandle 'Set up error handling.
FileName$ = COMMAND$      'Get file name.
KILL FileName$
PRINT FileName$ " deleted"
END
 
Errorhandle:
    Number = ERR
    IF Number = 53 THEN
       PRINT "Couldn't delete " FileName$ ;
       PRINT "; file does not exist in current directory"
    ELSE
       PRINT "Unrecoverable error:";Number
       ON ERROR GOTO 0   'ON ERROR GOTO zero aborts program.
    END IF
RESUME NEXT