I am working on a simple pdf that converts lbs -> kg, ft'in" -> cm and calculates BMI. If the user checks lbs then a hidden convertion field becomes visible (the ht. works in the same fashion).
I've been sucessful with my scripts for everything besides the BMI calculation part. Actually, the script works fine if you just keep clicking OK on the warning box and the calculation works! Also, the "Check Sript Syntax" doesn't pick up the error... I'm not sure what is wrong with the script to cause the warning dialog box even thought it works fine.
Any help would be appriciated.
Thanks!
if (q1.lbs2kg.Wt_lbs_Input.rawValue > 0 and q2.st2met.Ht_met_Cal.rawValue > 0) then
$.rawValue = q1.lbs2kg.Wt_kg_Cal.rawValue / ((q2.st2met.Ht_met_Cal.rawValue * .01) * (q2.st2met.Ht_met_Cal.rawValue * .01));
elseif (q1.lbs2kg.Wt_kg_Cal.rawValue > 0 and q2.met2st.Ht_met_Input.rawValue > 0) then
$.rawValue = q1.lbs2kg.Wt_kg_Cal.rawValue / ((q2.met2st.Ht_met_Input.rawValue * .01) * (q2.met2st.Ht_met_Input.rawValue * .01));
elseif (q1.kg2lbs.Wt_kg_Input.rawValue > 0 and q2.st2met.Ht_met_Cal.rawValue > 0) then
$.rawValue = q1.kg2lbs.Wt_kg_Input.rawValue / ((q2.st2met.Ht_met_Cal.rawValue *.01) * (q2.st2met.Ht_met_Cal.rawValue *.01));
elseif (q1.kg2lbs.Wt_kg_Input.rawValue > 0 and q2.met2st.Ht_met_Input.rawValue > 0) then
$.rawValue = q1.kg2lbs.Wt_kg_Input.rawValue / ((q2.met2st.Ht_met_Input.rawValue * .01) * (q2.met2st.Ht_met_Input.rawValue * .01));
endif
Also, its worth noting that the formula has to have 4 different conditions based upon how the user inputs the information.
Solved! Go to Solution.
Views
Replies
Total Likes
You have your expression on the calculate event. That event will fire when the form loads (and at this point there is no value). I would wrap your expression around a condition that checks if these fields are null or not. If they are null then they have not been filled yet and you should not do the calculation.
Paul
Views
Replies
Total Likes
I would like to add the pdf as an attachment on this thread, but I do not see an attachment button on the forum post?
This is a google doc share link. You will have to save it and then open it because google docs do not support dynamic pdfs.
Views
Replies
Total Likes
You have your expression on the calculate event. That event will fire when the form loads (and at this point there is no value). I would wrap your expression around a condition that checks if these fields are null or not. If they are null then they have not been filled yet and you should not do the calculation.
Paul
Views
Replies
Total Likes
I thought I accomplished that in the 'if' part of the script with rawValve.?
if (q1.lbs2kg.Wt_lbs_Input.rawValue > 0 and q2.st2met.Ht_met_Cal.rawValue > 0)
Also, I forgot to mention that this is in FormCalc
Views
Replies
Total Likes
If you check the value before you fill it I think you will find that it is null not 0.
Doesn't matter what language it is.
Paul
Views
Replies
Total Likes
I'd try the FormCalc HasValue() function.
if (HasValue(q1.lbs2kg.Wt_lbs_Input) and HasValue(q2.st2met.Ht_met_Cal))
(I think I have the syntax correct)
Oh, and with FormCalc you don't need ".rawValue" or the semicolons.
Issue Fixed, thanks Paul!
I had to change if (q1.lbs2kg.Wt_lbs_Input.rawValue > 0.. to if (q1._lbs2kg.count >= 1
Also, I ran into another issue (Arithmetic over/underflow) when the ht. values were expressed first b/c x/0 = unresolved. I resolved that by placing an if statement within an if statemtent to make sure values in the demoniator had to > 0
form1.#subform[0].BMI::calculate - (FormCalc, client)
form1.#subform[0].BMI::calculate - (FormCalc, client)
if (q1._lbs2kg.count >= 1 and q2._st2met.count >= 1) then
if (q2.st2met.Ht_st_Input > 1) then
$.rawValue = ceil(q1.lbs2kg.Wt_kg_Cal / Pow((q2.st2met.Ht_met_Cal * .01),2));
endif
elseif (q1._lbs2kg.count >= 1 and q2._met2st.count >= 1) then
if (q2.met2st.Ht_met_Input > 1) then
$.rawValue = ceil(q1.lbs2kg.Wt_kg_Cal / Pow((q2.met2st.Ht_met_Input * .01),2));
endif
elseif (q1._kg2lbs.count >= 1 and q2._st2met.count >= 1) then
if (q2.st2met.Ht_st_Input > 1) then
$.rawValue = ceil(q1.kg2lbs.Wt_kg_Input / Pow((q2.st2met.Ht_met_Cal * .01),2));
endif
elseif (q1._kg2lbs.count >= 1 and q2._met2st.count >= 1) then
if (q2.met2st.Ht_met_Input > 1) then
$.rawValue = ceil(q1.kg2lbs.Wt_kg_Input / Pow((q2.met2st.Ht_met_Input * .01),2));
endif
endif
Hope this helps others as well!
Views
Replies
Total Likes
Views
Likes
Replies