Good Day All;
I am now getting into forms that require some calculations. In doing some reading I have seen where both JavaScript and FormCalc are being used. Can anyone tell me which is the better to use?
For the form I am currently designing I have tried formCalc but I have hit a wee bump. I have ued the following “if(cost_p_h ne 0) thenSum(60/file_p_h) endif” and received the following error
Script failed (language is formcalc; context is xfa[0].form[0].form1[0].#subform[0].#subform[1].Table1[0].Row1[0].dur[0])
script=if(cost_p_h ne 0) thenSum(60/file_p_h) endif
Error: syntax error near token 'thenSum' on line 1, column 25.
I am currently running Acrobat Pro 8 and the version of LiveCycle Designer is 8.05
Thanks All.
Chomp
Solved! Go to Solution.
Views
Replies
Total Likes
It is becuase if files in blank it counts that as not equal to 0 so does the calculation. try:
if (files > 0) then
Sum(60/files)
else $ = ""
endif
Views
Replies
Total Likes
Hello Chomp,
In your script you should give a space between then and Sum as follows:
“if(cost_p_h ne 0) then Sum(60/file_p_h) endif”
Hope,this will help you.
Thanks,
Debadas.
Views
Replies
Total Likes
Thanks Debadas;
I made the change to " if (cost_p_h ne 0) then Sum(60/file_p_h) endif
Then I get the following error
Script failed (language is formcalc; context is xfa[0].form[0].form1[0].#subform[0].#subform[1].Table1[0].Row1[0].dur[0])
script=if(cost_p_h ne 0) then Sum(60/file_p_h) endif
Error: arithmetic over/underflow.
Any thoughts?
Thanks
Chomp
Views
Replies
Total Likes
Hello Chomp,
You can not divide by zero, so you need to add code to only allow the division when you have a non-zero divisor.
So for this script Sum(60/file_p_h), you have check wheather file_p_h is non-zero.
if(file_p_h ne 0) then Sum(60/file_p_h) endif
Thanks,
Debadas.
Views
Replies
Total Likes
Sorry for taking so long to respond to your post Debadas.
I have used if(file_p_h ne 0) then Sum(60/file_p_h) endif and I am still getting the arithmetic over/underflow error.
I created a new simple form with 4 fields
position = dropdown with 3 entries
wage = numeric field
files= numeric field
cost = numeric field
As soon as I open the form I get the arithmetric over/underflow error (divide by 0)
I put the code in the "cost" field using show = calculate* if(files ne 0) then Sum(60/files) endif and the language = formCalc.
When I clear the error and enter a number in the "files" field, the calculation works.
I know I am missing something.. It is just the what.
Thanks again Debadas
Views
Replies
Total Likes
It is becuase if files in blank it counts that as not equal to 0 so does the calculation. try:
if (files > 0) then
Sum(60/files)
else $ = ""
endif
Views
Replies
Total Likes
Thank you very much. worked like a charm.... Not toooo sure why the "ne 0" did not work.
Chomp
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies