Help: Divide by Zero Errors | Community
Skip to main content
Level 2
November 7, 2005

Help: Divide by Zero Errors

  • November 7, 2005
  • 1 reply
  • 4020 views
Hi, can someone please advise me on how to avoid script failure alerts (like the one below), which are generated because certain calculations are being performed before any positive value has yet been set in a numeric field?



Here is an example of the calculation:



--- form1.SF_CalculationTable.acview[0]::calculate - (FormCalc, client) --



(ac[0] / tr[0]) * 100



Error example:



Script failed (language is formcalc; context is

xfa[0].form[0].form1[0].SF_CalculationTable[0].acview[0])

script=(ac[0] / tr[0]) * 100

Error: arithmetic over/underflow.



update: it appears these erros are "divide by zero" errors.

So my questions are,

(1) would I put any javascript (to override the zeros) on the "validate" event or the "calculate" event, and on which of the three fields in question, acview[0] (the result), tr[0] (the denominator) or ac[0] (the numerator). and...



(2) What might that javascript look like?



--

Harry
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

July 15, 2010

Your error message indicates your script is being executed as FormCalc, not JavaScript.

If you're using FormCalc try using an If statment to test for zero/null.

if (tr>0) then (ac/tr)*100 endif