Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!beach.cis.ufl.edu!dor From: dor@beach.cis.ufl.edu (Douglas R. Oosting) Newsgroups: comp.lang.pascal Subject: Re: Trapping (fatal) runtime errors in TP 5.0 Keywords: Exit procedures Message-ID: <20892@uflorida.cis.ufl.EDU> Date: 15 Sep 89 13:31:31 GMT References: <486@oetl1.oetl.UUCP> Sender: news@uflorida.cis.ufl.EDU Reply-To: dor@beach.cis.ufl.edu (Douglas R. Oosting) Distribution: usa Organization: UF CIS Department Lines: 34 In article <486@oetl1.oetl.UUCP> randy@oetl.UUCP (Randy O'Meara) writes: > > Does anyone know how to trap the fatal runtime errors in > Turbo 5.0? I'm interested in recovering from real math > overflow. Thanks. > Its fairly simple...you declare a procedure for error-handling somewhere in your code. Put a {$F+} and a {$F-} compiler directive around it [force far call ON for the procedure, turn it back OFF afterwards] Now, in your initialization code, make these two declarations... ExitSave := ExitProc [ExitProc is declared for you, ExitSave is a POINTER] ExitProc := @MyErrorProc (or whatever) The last statement of your error handler (refered to as MyErrorProc above) must be ExitProc := ExitSave (Exiting a program is a chain procedure; this process inserts your trapper *before* the Turbo one. It will be called every time you exit, so you will want to check the error condition to make sure you *need* to do anything. Doug Oosting >-- >Randy O'Meara randy@oetl.Scf.Lockheed.Com >(408) 425-6249 ...{pyramid,leadsv,lstc}!oetl!randy -- Entropy Requires | Douglas R. Oosting, University of Florida No maintenance... | dor@beach.cis.ufl.edu or Pendragon@oak.circa.ufl.edu --Markoff Chaney |...{mailrus|gatech}!uflorida!beach.cis.ufl.edu!dor In the Society : Cadrys ap Dulas o Caereira, Barony of An Crosaire, Trimaris