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

If function Form Calc am i stupid????

beachbumbali11
Registered: Mar 5 2008
Posts: 74

Ok i am totally lost is my program messed up am i missing something totally obvious?
I have three text Fields respectively named 1,2,3 here is the code placed into calculation

if ( form1.#subform[0].Field1 < form1.#subform[0].Field2 ) then
Field3 = 0
elseif ( form1.#subform[0].Field1 > form1.#subform[0].Field2 ) then
Field3 = 40
elseif ( form1.#subform[0].Field1 = form1.#subform[0].Field2 ) then
$ = 10

I copied it out of the form calc reference manual but I keep getting syntax errors near the Field3 = 0
What am i doing wrong????????

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Don't beat yourself up about this stuff. Minor details can kill you, and the documentation isn't exactly clear.

There are a few issues with the code, not all of them fatal.

1. The error is caused by using "=" as the comparison operator in the last if. The correct syntax is to use "==":

elseif ( form1.#subform[0].Field1 == form1.#subform[0].Field2 ) then

2. There is no "endif". But I imagine you just didn't copy that over to the post. But if it's missing, then this is a bug.

3. It's a good practice to rename the Page Level subforms to something more meaningful than "#subform[0]". I like to use "P1", "P2", etc. because it's easy to type and reminds me that these are at the page level.

4. If all the fields are on the same hierarch level as the field with the calculation script, then there is no need to include the full path to the fields you want to test. You can reference "Field1" and "Field2" directly.

5. For calculations, or any script inside a field event. Refer to the current field with $, like you have in the last assignment. This makes your code consistent.
However, the assignment is completely unnecessary. In a calculation script. The last value executed in the script, is the value applied to the calculation, regardless of any assignment.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

beachbumbali11
Registered: Mar 5 2008
Posts: 74
Thank you I got the solution by breaking down every line one by one and solved it with a string less than 1 but thanks so much for answering my question.
Who wrote this freaking formcalc user reference any way its misspelled and to include three samples that dont work in the book has had me banging my head against a wall for three days.

I truly appreciate the help and your samples in acrobat are wonderful references is there any where to find similar ones for Live Cycle?