home *** CD-ROM | disk | FTP | other *** search
- Critical errors like an open disk drive or adisconnected
- printer result in the DOS message "Abort, Retry,Ignore,
- Fail?" without saving the current display, thusruining the
- application screen.
-
- Turbo Pascal 4.0 allows you to write procedures whichare
- labelled INTERRUPT which automatically save all theregisters
- and restore them when returning. In addition, youcan modify
- the registers within the procedure, and thosechanges are
- passed back to DOS. No more need for routineswritten in
- assembler !
-
- I have used this new ability of TP4 to write a
- criticalerror handler unit. When it is incorporated in
- theapplication it will save the screen, ask for a response,
- passthe response back to DOS, and restore the
- application'sscreen intact.
-
- Beginning with DOS 3.0 the DOS technical reference
- saysyou should not code to correct specific errors, even
- thoughyou can present a message which is quite specific.
- Instead,you are told to follow the suggested action indicated
- by DOSthrough INT 59h, GetExtError. This is now the
- preferredmethod of error trapping according to the Blue
- Bible. Theregisters will also let you know the location of
- the error,generally, and the type of error, generally, as
- shown below.
- Other critical error handlers in the public domain
- don'tuse this format probably because it is only useful for
- thosewho use DOS 3.x. This program checks the DOS version
- and ifit is < 3.x finds the DOS error number by looking at
- lo(DI)which contains the old DOS critical error number and
- thenconverts it to the new extended error numbers by adding
- 19 toit. It then extracts what other information it can from
- theregisters. You can then use the error message pointed to
- bythe resulting number, and the other information, but
- youdon't get a suggested correction, you may get
- unexpectedanswers in the future, and you transgress.
-
- See the program listing for the specific codes and
- theirmeanings.
-
- Other methods are available for dealing with errors
- aswell. They are included in the unit.
-
- You can disable IO checking and call IOResult,
- thenhandle the error in a more specific way than just
- allowingabort retry ignore fail. If you use the INT24 unit
- from theEditor Toolbox you can trap critical errors this way
- as well,and take specific action to correct the situation.
-
- Finally, you should have an exitprocedure to clean upand
- to catch errors you otherwise wouldn't expect, likeheap space
- errors. That's here too.ß▄ßj ß▄ßßîß▄j ▄î Printer Errors are another story. Although the
- printerif off will trigger INT24h, if it is only off line or
- out ofpaper, no trap takes place. I've included a check for
- theprinter status in the code using INT 17h which may be
- useful. Be careful though, because NONE of these traps an
- error withmy HP ThinkJet. Most other printers I've tried
- respond asexpected.
-
- Another value of the program is the use of the heap
- tostore the error messages. Although TP4 allows multiple
- codesegments so that code can exceed 64K, it still only
- allowsone data segment, and so only 64K of data. In
- addition,typed constants have been moved to the data segment
- as well,so that older trick of hiding them in the code
- segment nolonger works. To overcome this limitation it is
- necessary to use the heap to store data. That is why I chose
- to use thepointer structure to hold the long list of error
- messages.
-
- Thanks to a suggestion by Scott Bussinger, this revision
- removes dependence on TP4 read and write procedures and color
- settings, and windowing functions.
-
- Using the TP4 procedures resets certain constants like
- IOResult, and can result in the system hanging. In addition,
- the use of the pointer method of screen swapping in the
- earlier version results, on an IBM color card, in snow on the
- screen. Finally, the earlier version didn't keep track of
- the cursor position of the prior screen, so that the state of
- the screen on return was unpredictable.
-
- I have used a variety of routines picked up from other
- users of this forum to overcome some of these problems, and
- they are in the include files used. They are valuable in
- other situations as well.