KILL Statement Example
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
' This example deletes the file specified on the command line. Note: Choose
' Modify COMMAND$ from the Run menu to specify a file to delete.
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
DEFINT A-Z
CLS ' Clear the 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 ' Aborts program
END IF
RESUME NEXT