-1

I'm coding a program with Pascal in fastreport, The problem appear when I try to show the result of a division. this is my program:

var
relec_tp_for_pa, tp_for_pa, relec_tt_tp, total_tp, coef_relec : Real = 0;
relec_vt : Integer = 0;

procedure MasterData1OnBeforePrint(Sender: TfrxComponent);               
begin

if ( ( <EJobsQuery."SERV_ID"> = 54 ) )  then        
   begin
       relec_tp_for_pa := tp_for_pa;                                      
       relec_vt := relec_vt + <EJobsQuery."EJOB_VOLUME">;                                      
       relec_tt_tp := relec_tt_tp + tp;
       total_tp := total_tp + tp;
   end;

coef_relec := StrToFloat(FormatFloat('0.0000', relec_tt_tp / total_tp));

relec_pa.Text := FormatFloat('0.00', relec_vt /(relec_tp_for_pa * coef_relec));                
relec_pr.Text := FloatToStr( relec_vt / relec_tt_tp );                 

end;

Both of this divisions:
-relec_vt /(relec_tp_for_pa * coef_relec)
-relec_vt / relec_tt_tp
are giving me the error : Invalid Floating point operation

I'm coding in the FastReport 4.11.4 a report. under 32 bits OS if this can help.

Thanks again.

S. Bertit
  • 7
  • 5

1 Answers1

4

From what you've coded it seems that You divide by zero!

-relec_vt /(relec_tp_for_pa * coef_relec)

-relec_vt / relec_tt_tp

Since

relec_tp_for_pa := tp_for_pa

is definetly ZERO!

relec_tp_for_pa * coef_relec 

Will also be zero!

For relec_tt_tp I just can try to guess, since this code is not a complete example.

total_tp := total_tp + tp

total_tp is zero, and if tp is also zero You'd end up in a division by zero.

Generally I'd always check if your divisor is not zero!

Community
  • 1
  • 1
Alexander Baltasar
  • 1,044
  • 1
  • 12
  • 25