home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / tptools.zip / FIRSTED.ZIP / ERRORS.PAS < prev    next >
Pascal/Delphi Source File  |  1987-12-21  |  2KB  |  74 lines

  1. {                          ERRORS.PAS
  2.                         Editor Toolbox 4.0
  3.              Copyright (c) 1985, 87 by Borland International, Inc.            }
  4.  
  5. {$I-}
  6. {$R-}
  7. {$S-}
  8. {$V-}
  9. {$D-}
  10.  
  11. unit Errors;
  12.   {-Reports on runtime errors and shuts down gracefully}
  13.  
  14. interface
  15.  
  16. uses
  17.   Dos;                       {DOS interface - standard unit}
  18.  
  19.   {==========================================================================}
  20.  
  21. implementation
  22.  
  23. var
  24.   ExitSave : Pointer;
  25.   DosBreakState : Byte;      {Initial state of DOS break checking}
  26.  
  27.   function GetDosBreakState : Byte;
  28.     {-Return the current state of DOS break checking}
  29.   var
  30.     regs : registers;
  31.  
  32.   begin                      {GetDosBreakState}
  33.     with regs do begin
  34.       ax := $3300;
  35.       intr($21, regs);
  36.       GetDosBreakState := dl;
  37.     end;
  38.   end;                       {GetDosBreakState}
  39.  
  40.   procedure SetDosBreakState(State : Byte);
  41.     {-Set the current state of DOS break checking}
  42.   var
  43.     regs : registers;
  44.  
  45.   begin                      {SetDosBreakState}
  46.     with regs do begin
  47.       ax := $3301;
  48.       dl := State;
  49.       intr($21, regs);
  50.     end;
  51.   end;                       {SetDosBreakState}
  52.  
  53.   {$F+}                      {Must be far call}
  54.   procedure UserExitProc;
  55.     {-Executed upon errors and at normal termination of program}
  56.  
  57.   begin                      {UserExitProc}
  58.     {Restore control to previous exit handler}
  59.     ExitProc := ExitSave;
  60.     {Restore DOS break state}
  61.     SetDosBreakState(DosBreakState);
  62.   end;                       {UserExitProc}
  63.   {$F-}
  64.  
  65. begin
  66.   {Set up ExitProc}
  67.   ExitSave := ExitProc;
  68.   ExitProc := @UserExitProc;
  69.  
  70.   {Store current DOS break checking state and turn it off}
  71.   DosBreakState := GetDosBreakState;
  72.   SetDosBreakState(0);
  73. end.
  74.