Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Two-Minute Lecture on ErrorMode Function No-Nos

Keywords:   errormode(@off) errormode(@cancel)

Read ALL the stuff about errormode in the manual. Only disable Errormode for one line at a time. Turning Errormode(@off) is a very big no-no almost all the time.
  1. Use of Errormode indiscriminately will turn a 5 minute debugging project into a 6 week project.

  2. ONLY put error mode around SINGLE statements where you are handling the errors yourself. If it is obvious that there is no way a statement could fail it should be run with ErrorMode(@CANCEL)

  3. The problem is that the most mindless errors that you do not bother to check for will be the ones that set up a condition that causes a catastrophe 20 statements later.

  4. Here's the famous case:

    User writes a script that deletes all the temp files from his temp directory at startup. Sometimes there are no files so errors were suppressed to avoid messages. Script read:

            ErrorMode(@OFF)
            DirChange("C:\TEMP")
            FileDelete("*.*")
    
    and he put the script in his startup directory. Everything ran fine for months.

    Then, being short of disk space on C:, moved the temp directory to D:\TEMP

    Next time boot up occurred, the script was run. The DirChange failed but because error mode was @OFF, the script continued to run.

    Needless to mention, the FileDelete("*.*") performed flawlessly. Too bad it was not pointing to any intended directory.

  5. Use of ErrorMode(@OFF) at the top of your script WILL nail you every time. Basically your Faustian bargains are:

    • Your script will sometimes put an error message up in front of the user for untrapped errors. Your programming abilities will be held up to ridicule.

    • Your script will occasionally trash a computer requiring reformatting the hard drive and re-installing windows, losing all the users files in the process. This will be pointed out to your management. The humor of the situation will not be a migitating factor.

Article ID:   W12710
Filename:   Two Minute Lecture on ErrorMode No-Nos.txt