home *** CD-ROM | disk | FTP | other *** search
- { ERRORS.PAS
- MS 4.0
- Copyright (c) 1985, 87 by Borland International, Inc. }
-
- {$I-}
- {$R-}
- {$S-}
- {$V-}
- {$D-}
-
- unit Errors;
- {-Reports on runtime errors and shuts down gracefully}
-
- interface
-
- uses
- Dos; {DOS interface - standard unit}
-
- {==========================================================================}
-
- implementation
-
- var
- ExitSave : Pointer;
- DosBreakState : Byte; {Initial state of DOS break checking}
-
- function GetDosBreakState : Byte;
- {-Return the current state of DOS break checking}
- var
- regs : registers;
-
- begin {GetDosBreakState}
- with regs do begin
- ax := $3300;
- intr($21, regs);
- GetDosBreakState := dl;
- end;
- end; {GetDosBreakState}
-
- procedure SetDosBreakState(State : Byte);
- {-Set the current state of DOS break checking}
- var
- regs : registers;
-
- begin {SetDosBreakState}
- with regs do begin
- ax := $3301;
- dl := State;
- intr($21, regs);
- end;
- end; {SetDosBreakState}
-
- {$F+} {Must be far call}
- procedure UserExitProc;
- {-Executed upon errors and at normal termination of program}
-
- begin {UserExitProc}
- {Restore control to previous exit handler}
- ExitProc := ExitSave;
- {Restore DOS break state}
- SetDosBreakState(DosBreakState);
- end; {UserExitProc}
- {$F-}
-
- begin
- {Set up ExitProc}
- ExitSave := ExitProc;
- ExitProc := @UserExitProc;
-
- {Store current DOS break checking state and turn it off}
- DosBreakState := GetDosBreakState;
- SetDosBreakState(0);
- end.