How to erase Ezerodivide message in Delphi ?

Started by fredvs,

fredvs

Sorry to ask that, But sometimes its usefull for Bass...

How is it possiBle to disaBle the error message, if i do
like folow, it get always the error message...
 
procedure TForm1.Button1Click(Sender: TObject);
var
f : real ;

begin
  f := 0 ;
try
 Button1.Caption := inttostr(round(5 / f)) ;
 except
 on Ezerodivide do  Button1.Caption :=  'Abort'  ;
end;
end;

I get always the error message, how must i do to disaBle it ?

AndrewJameson

Hi Fred,
This really hasn't got much to do with Bass ... you should post this to the Borland user group !  Anyway, you have succeeded in what you wanted to do ... the exception is trapped and the caption for the button is revised.  I think that you're testing within Delphi's IDE and its debugger will still continue to trap exceptions ... so you could turn debugging off which isn't a good idea ...certainly if you run the compiled code outside the IDE it runs fine.

But ... this example is NOT good programming practice ... trapping exceptions should be used for exactly that condition ... an error that you can't detect with 100% confidence ... a rare event over which you've no control ... in your case you can test for zero division (or near zero division) before actually doing it ...

Andrew


fredvs

Of course it is not a good sample of program !

I ask that because i use the beat counter dll of Jim.
It works fine but sometimes (it depend of the stars) i get a message 'Invalid floating point operation. Divize y zero'.

If i click OK, it works fine.

How cant discard that message ?

georgebou

Simply Delete the Line
on Ezerodivide do  Button1.Caption :=  'Abort'  ; ;D

The on Ezerodivide exception is needed if you want to do special handling to this exception.

fredvs

Sorry, if i Simply Delete the Line, i get also the error message... :-/

dave

I get the same thing happening in Delphi too. Hard to control when it's the dll that gives you the error. Maybe Jim could answer this one.

Ingolf3

Maybe I don't understand?

if f > 0 then Button1.Caption := inttostr(round(5 / f))
else Button1.Caption := 'Abort';

???

(: JOBnik! :)

#7
Hi ;D

The problem is inside the BPM.DLL, I've checked the source code of the SoundTouch BPM detector, and found out that there're some unhandled errors in there.

I've included the BPM detection in Next version of BASS_FX, plus there're some more DSP FX added, if someone wants to Test it I could send it, btw the BPM detection is much easier and has more features ;)

Have fun!

8) JOBnik! 8)

dw

You have two problems. Even though you cover your butt with Ezerodivide you also have to cover EInvalidOp when Jim's dll divides 0 by 0.

The second problem is to get out of Delphi (or VB) and try the program from clicking on the compiled exe. If you run it from within Delphi, you will always get the error messages coming up (if you are using Delphi's default setting). If you stay in Delphi, after you get the error message, click OK and then run again. It will continue from there.

try
  detbpm := Get_BPM(); // Store the found BPM
except
on Ezerodivide do
 BEGIN
 label1.caption := 'Failed';
 detbpm:=-2; //or whatever
 end;
on EInvalidOp do
 BEGIN
 label1.caption := 'Failed';
 detbpm:=-2; //or whatever
 end;
 
 if detbpm >= 1 then
  begin
  label2.caption := floattostr(detbpm); // Show the stored BPM
end;

Hope that helps.
Dave