Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #7832 > unrolled thread

Why doesn't the error handler catch division by 0?

Started byD.J.W. van Kooten <vankooten@removethis.ic2.com>
First post2015-03-06 00:33 +0100
Last post2015-03-10 11:28 +0100
Articles 6 — 4 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  Why doesn't the error handler catch division by 0? D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2015-03-06 00:33 +0100
    Re: Why doesn't the error handler catch division by 0? kw@e©os-system.dot.de - 2015-03-06 08:49 +0100
      Re: Why doesn't the error handler catch division by 0? D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2015-03-06 14:52 +0100
    Re: Why doesn't the error handler catch division by 0? Malcolm G <malcolm-news2012delete@delete.jobstream.com> - 2015-03-06 09:24 +0000
    Re: Why doesn't the error handler catch division by 0? Sherlock <sherlock@sherlock.com.au> - 2015-03-10 00:36 -0700
      Re: Why doesn't the error handler catch division by 0? D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2015-03-10 11:28 +0100

#7832 — Why doesn't the error handler catch division by 0?

FromD.J.W. van Kooten <vankooten@removethis.ic2.com>
Date2015-03-06 00:33 +0100
SubjectWhy doesn't the error handler catch division by 0?
Message-ID<sbphfa9sf202jf8hnpm33nbrsu24ijqds0@4ax.com>
The code below doesn't handle a division by 0 but gives a 'An
unhandled exception error occured in module VO28GUI.DLL or your
application!

However, an array[0] access is handled by the RECOVER code:

LOCAL cobOldErrFunc AS USUAL
LOCAL a:={} AS ARRAY
bLastHandler := ErrorBlock({|oErr| MyHandler(oErr, TRUE)})
cobOldErrFunc := ErrorBlock( {|oErr|_Break(oErr)} )
BEGIN SEQUENCE
	n:=0
	n2:=5/n	// This does not go to RECOVER
	n2:=a[0]	// This does go to recover
RECOVER 
	MessageBox(SELF:Handle(),String2Psz("Run time error
"),String2Psz(""),MB_OK)	
END SEQUENCE
ErrorBlock(cobOldErrFunc) 


Why wouldn't it handle the division by zero error I was wondering?

Dick

[toc] | [next] | [standalone]


#7833

Fromkw@e©os-system.dot.de
Date2015-03-06 08:49 +0100
Message-ID<clt4giFnqejU1@mid.individual.net>
In reply to#7832
Hi Dick,

I don't see your problem here, everything works as expected ...

Just some questions:

bLastHandler := ErrorBlock({|oErr| MyHandler(oErr, TRUE)})
What is this line good for ? What happens if you delete it ?

How are n and n2 declared ?

Karl

Am 06.03.2015 um 00:33 schrieb D.J.W. van Kooten:
>
> The code below doesn't handle a division by 0 but gives a 'An
> unhandled exception error occured in module VO28GUI.DLL or your
> application!
>
> However, an array[0] access is handled by the RECOVER code:
>
> LOCAL cobOldErrFunc AS USUAL
> LOCAL a:={} AS ARRAY
> bLastHandler := ErrorBlock({|oErr| MyHandler(oErr, TRUE)})
> cobOldErrFunc := ErrorBlock( {|oErr|_Break(oErr)} )
> BEGIN SEQUENCE
> 	n:=0
> 	n2:=5/n	// This does not go to RECOVER
> 	n2:=a[0]	// This does go to recover
> RECOVER
> 	MessageBox(SELF:Handle(),String2Psz("Run time error
> "),String2Psz(""),MB_OK)	
> END SEQUENCE
> ErrorBlock(cobOldErrFunc)
>
>
> Why wouldn't it handle the division by zero error I was wondering?
>
> Dick
>

[toc] | [prev] | [next] | [standalone]


#7837

FromD.J.W. van Kooten <vankooten@removethis.ic2.com>
Date2015-03-06 14:52 +0100
Message-ID<cnbjfatpaqv7ntbqueb40se05b1asp5m1i@4ax.com>
In reply to#7833
On Fri, 06 Mar 2015 08:49:38 +0100, kw@e©os-system.dot.de wrote:

Hello Karl, Malcolm,

>bLastHandler := ErrorBlock({|oErr| MyHandler(oErr, TRUE)})

This was a line from a previous experiment.

>What is this line good for ? What happens if you delete it ?
>
>How are n and n2 declared ?

As DWORD - which should give a run time error as well on dividing.

>The code below does not specify the compiler options used?

@Malcolm: Yes, that's it. I always have the Clipper Compatibility off,
except Procline/Name. Doesn't sound something I need in 2015 but
apparently integer Division is required to catch this error!

No idea what it has to do with "Clipper compatibility" and what it has
to do with run time errors (I'd expect it is only that the compilers
warns for possible integer divisions) but it does appear to make the
difference.

Dick

[toc] | [prev] | [next] | [standalone]


#7834

FromMalcolm G <malcolm-news2012delete@delete.jobstream.com>
Date2015-03-06 09:24 +0000
Message-ID<XmeKw.848196$gq5.131420@fx46.am4>
In reply to#7832
On 05/03/2015 23:33, D.J.W. van Kooten wrote:
> 
> The code below doesn't handle a division by 0 but gives a 'An
> unhandled exception error occured in module VO28GUI.DLL or your
> application!

The code below does not specify the compiler options used?

[toc] | [prev] | [next] | [standalone]


#7849

FromSherlock <sherlock@sherlock.com.au>
Date2015-03-10 00:36 -0700
Message-ID<3c00c992-2ee1-4703-bdd2-7a99c3de478a@googlegroups.com>
In reply to#7832
Dick

snip[ Why wouldn't it handle the division by zero error I was wondering? ]

When Vo starts up and app you can set up things you want using _INIT2 and _INIT3

As an example "PROCEDURE InitCAPaint() PASCAL _INIT3..  are serviced before you get to say Function Start() or Method Start() CLASS this code has been run.

Knowing this you can use say PROCEDURE ErrorSys() PASCAL _INIT2 to set up your own error handling system. THat is override the way you want. So in my library I this. In this code you deal with trapping Division by ZERO or any number of error handling conditions. I have this and memo repairing etc.
Been ages and ages since I ever worked on this .. but it works.

In this code I have ;

   IF (oError:GenCode == EG_ZERODIV )
	RETURN 0
   ENDIF


 
Phil McGuinness

[toc] | [prev] | [next] | [standalone]


#7852

FromD.J.W. van Kooten <vankooten@removethis.ic2.com>
Date2015-03-10 11:28 +0100
Message-ID<3qhtfatn9f3trpfa2duqb6tfck07iq50pa@4ax.com>
In reply to#7849
On Tue, 10 Mar 2015 00:36:20 -0700 (PDT), Sherlock
<sherlock@sherlock.com.au> wrote:

Hello Phil,

>Knowing this you can use say PROCEDURE ErrorSys() PASCAL _INIT2 to set up your own error handling system.
> THat is override the way you want. So in my library I this... but it works.
>
Never realized that, very interesting. Thanks.

Dick

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web