home *** CD-ROM | disk | FTP | other *** search
- (* INT24 -- A unit for trapping DOS critical errors (INT 24) for retries.
-
- Version 1.01 - 01/02/1987 - First general release
-
- Scott Bussinger
- Professional Practice Systems
- 110 South 131st Street
- Tacoma, WA 98444
- (206)531-8944
- Compuserve 72247,2671
-
- Turbo Pascal version 4.0 added a paticularily nice feature in that it
- automatically installs a critical error handler (INT 24) to keep DOS from
- putting up the familiar 'Abort, Retry, Ignore?' messages. Instead of putting
- a message in the middle of your nice screens, you can now detect the errors
- and act on them yourself. Unfortunately, you've also lost the ability to retry
- an error and let execution continue after fixing the problem without lots of
- programming effort. This UNIT provides a special handler to display an error
- message on critical errors and allow the user to attempt to correct the
- problem and try it again. If the user decides not to retry it, the program
- returns the normal error codes for critical errors. The unit automatically
- saves the users screen so that the error message doesn't mess up any screen
- displays. To include this unit in your program, add Int24 to the USES clause
- in your main program.
- In general, when a critical error occurs, the INT24 unit first saves a copy
- of the users screen. It thens blanks the screen, warbles at the user and
- displays an error message in the middle that explains what happened and waits
- for the user to hit a key. If 'A', 'Q', ^C, Esc or ^Break is hit, the screen
- is restored and an error code is returned to the program. If any other key is
- hit, the screen is displayed and the operation tried again. If the error has
- not been corrected, the message will appear again.
- The unit also allows you to install a special critical error handler in
- addition to the default handler in case you want to check for special cases
- on an individual basis (e.g. to not allow retries on write-protect errors).
- This demonstration program requires some special routines to play with the
- cursor and write directly to the screen. You must either use Brian Foley's
- FASTWR unit and my own CURSORS unit (both of these public domain packages are
- available on Compuserve) or use the TPCrt unit from Turbo Power Software's
- Turbo Professional package (Turbo Power Software can be reached in CA at
- (408)438-8608). The program uses conditional compilation to choose between
- the two alternatives. To use with the Turbo Professional routines include a
- {$DEFINE TPROF}
- line at the beginning of the INT24 unit before compiling.
-
- If you compile this file, the resulting program will attempt to create a
- file on drive A. Try leaving the disk out and running the program. Then try
- it with a disk in. Now try it with a disk with a write-protect tab
- attached. Try both continuing without fixing the problem and then try
- aborting by hitting ^C. Now run the program again (still with the write-
- protect tab) and remove the disk before hitting the key. Then one last time
- removing the write-protect tab when the program suggests it. *)
-
-
- program Test;
-
- uses Int24;
-
- {$I-}
-
- var I: Integer;
-
- procedure FileTest;
- var F: file;
- begin
- writeln('Testing for critical errors by writing to drive A:');
- I := IOResult;
- assign(F,'A:FILE');
- I := IOResult;
- rewrite(F);
- I := IOResult;
- if I <> 0
- then
- writeLn('Create failure on A:FILE : IOResult=',I)
- else
- begin
- writeln('A:FILE created.');
- I := IOResult;
- close(F);
- I := IOResult
- end
- end;
-
- begin
- FileTest
- end.