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????????
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