Reflections on the Infamous KILL Statement

by Welopez

I've been programming as a hobbyist for nearly 30 years, and I have yet to use the KILL statement unless I am updating a data file, making a backup of the data, and then use KILL to delete oldFile.txt and allow renaming newFile.txt as oldFile.txt.

It's not that I am a pacifist or anything; I spent 30 months in combat where I was expected and encouraged to KILL the enemy. When not in combat, indiscriminate KILL-ing is certain to get you talked about by your neighbors!

When new programmers do not understand the proper meaning and use of KILL, they often give BAD advice. Recently a user asked how to end a running instance of Internet Explorer and a newbie recommended KILL "C:\Program Files\Internet Explorer\iexplore.exe"

WRONG! DEAD WRONG! The KILL command means to DELETE the named file from your hard-drive! Our helpful newbie had no idea what he had just suggested! Fortunately, if another user had taken this advice, Internet Explorer WOULD NOT have been deleted if the program were running. Windows will protect you from your folly by not allowing you to delete a currently running file. Thank goodness!

If Internet Explorer had not been running, it would have been deleted from the user's computer without even a "Are you sure you want to send fileName.exe to the recycle bin? warning. Poof! The poor schmuck who issued the KILL command would now have to download all 15 MB of Internet Explorer again, or download another browser. Installing a new browser is not a problem, but there are many applications on your computer which access Outlook Express, and the email client is bundled with Internet Explorer! Ouch!

Try this demo:

      'A DEMO to KILL a test file
      'by Welopez

      OPEN "killTest.txt" FOR APPEND AS #1
      PRINT #1, "The quick brown fox jumps over the lazy dog."
      PRINT #1, "Pack my box with five dozen liquor jugs."
      PRINT #1, "The quick brown fox jumps over the lazy dog."
      PRINT #1, "Pack my box with five dozen liquor jugs."
      CLOSE #1

      OPEN "killTest.txt" FOR INPUT AS #1
      INPUT "Do you wish to KILL the test file? (Y/N) "; resp$
      resp$=UPPER$(resp$)
      IF LEFT$(resp$,1)="Y" THEN
      '    CLOSE #1
          KILL "killTest.txt"
      ELSE
          CLOSE #1
          GOTO [quit]
      END IF

      WAIT
      [quit]
      END

Each time you run this program, four lines of nonsense text will be added to killTest.txt. If you choose "Y" to kill the test file, an error occurs because the file is currently in use. NOTE: CLOSE #1 has been remmed out in the IF/THEN/ELSE block. Remove the apostrophe and run the code again, choosing "Y" this time.

Acradabra, alakazaam! Poof! The test file has been deleted!

Just as it is rude to go around KILL-ing your neighbors, it is unpardonable for a programmer to write code which will KILL files on the user's computer - - WITH THE EXCEPTION of files created by the program and no longer needed! GOD can KILL people He created, but you must not!

Let me rephrase that just to be politically correct in the event some users may be an agnostic or atheist: Mother Nature can do as she will; and their ain't diddly you can do about it! Or, "Never underestimate the power of human stupidity!"

As a programmer, you are a demi-God and permitted to KILL files you create, but if you fool around and KILL files on my computer, files I may need for my own use, I'll track you down point out the error of your ways in the most excruciatingly painful manner I can devise!

It ain't nice to fool Mother Nature