Expand my Community achievements bar.

Syntax Error on FormCalc Scripts

Avatar

Former Community Member

I am trying to write a script that divides one cell with another. I first got an arithmetic error and went to the blogs and found out that's becuase it was trying to divide it by zero. So, I followed the suggested formula, which is an if/then formula:

a4.rawValue = if (a2.rawValue>0) then (a3.rawValue/a2.rawValue) endif

However, when I do this, I get the following error:

Syntax error near token 'then' on line 2, column 35.

I have tried using spaces, commas, everything and it just will not go away. I don't understand what I'm doing wrong or how this should be written as it is a very simple if/then calculation...

If anyone has any suggestions, I would greatly appreciate it as I am under the gun to get this figured out! Thanks,

1 Reply

Avatar

Level 10

You've got it a bit backwards.

Try:

if (a2 gt 0)

then

a4 = a3/a2

endif

(with FormCalc you don't need to use .rawValue.)

In your code you were assigning the if/then script as the value of the a4 field. You want to test the value of a2 and then get the value for a4 (or not).

You can find the FormCalc reference here:

http://help.adobe.com/en_US/livecycle/9.0/FormCalc.pdf