home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / ETRAP8.ZIP / TESTERR.DOC < prev    next >
Encoding:
Text File  |  1988-04-24  |  4.0 KB  |  24 lines

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