These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

calculating natural logarithm in LCD v8.0

rpeterson
Registered: Oct 7 2008
Posts: 72
Answered

Hi All,
Ok here is my latest dillema...
I am trying to script a calculation for ln(I/Io) where I and Io are calculated cells within a table. I am using a separate data entry area where the analyst only needs to enter in the individual readings and the form will calculate using those entries. Everything appears to be working fine until I ask for log(x) or Math.log(x) or Math.ln(x). Here is my script:

----- form1.Main_Subform.Subform2.SRS1Table.Row1.Cell5::calculate: - (JavaScript, both) ------------

var Abs1a = (form1.Main_Subform.Subform2.SRS1Table.Row1.Cell2.rawValue / form1.Main_Subform.Subform2.SRS1Table.Row1.Cell4.rawValue)

if (HasValue(form1.Main_Subform.Subform2.SRS1Table.Row1.Cell2.rawValue) and HasValue(form1.Main_Subform.Subform2.SRS1Table.Row1.Cell4.rawValue))
this = Math.log(Abs1a.value);
else
" ";

I get no error messages at all when previewing.

I have tried defining variables to condense the scripts, but that does not seem to work either. So other than the variable listed in the above script, the others will need deleted (I think).

Can anyone help me with the language or format or anything else that will straighten this one out.

rpeterson

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Are you providing for the possablity of division by zero?

"this" alone has no meaning. "Abas1a.value" has no meaning because 'Abas1a' is a variable and not an object.

Have you checked Acrobat's JavaScript debugging console for errors?

George Kaiser

rpeterson
Registered: Oct 7 2008
Posts: 72
gkaiseril,
Yes, I finally started the debugging console. I worked through all the issues that it came up with. It turns out that the var was not needed. HasValue was not usable in JS. As well as the 'else' part of the conditions was being seen as a syntax error. I also found that I was using an incorrect cell in one of the calculations. So here is the final script:

if(form1.Main_Subform.Subform2.SRS1Table.Row1.Cell2.rawValue >= 0 && form1.Main_Subform.Subform2.SRS1Table.Row1.Cell4.rawValue >= 0);
{
Math.log(form1.Main_Subform.Subform2.SRS1Table.Row1.Cell2.rawValue / form1.Main_Subform.Subform2.SRS1Table.Row1.Cell4.rawValue);
}

So, you saw all the messes that I included in the script. Thanks so much.

rpeterson