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

Positive Values

mtavares
Registered: Apr 14 2011
Posts: 25
Answered

Hi,
I have a numeric fielde that change by calculate event. So i want that when a value of result is a negative (field value < 0)this show a zero ( 0 ) and nothing like "-2500". There are any way to set field is just positive and integer number/value?

Manuel Tavares

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
In your calculation script, include an 'if' statement to change the result of the calculation to zero. The 'if' statement is described in the "Scripting Reference" under the 'Help' menu.

George Kaiser

mtavares
Registered: Apr 14 2011
Posts: 25
Accepted Answer
gkaiseril wrote:
In your calculation script, include an 'if' statement to change the result of the calculation to zero. The 'if' statement is described in the "Scripting Reference" under the 'Help' menu.
I use already use it. I type in calculate event but it didn't work. I'll test more times and look what's problem!

thank you...

Manuel Tavares

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
I can not see the code.

Have you looked at the JavaScirpt console to see if there are any errors?

var MyAns = 0;
// perform the calculation and put the answer in the MyAns variable

// test for a less than zero result
if(MyAns < 0) then
// force result to zero
MyAns = 0
endif
// insert result into field.
MyAns

George Kaiser

mtavares
Registered: Apr 14 2011
Posts: 25
The code is like you post, it's because i think so it's strange... by logic this should worked!!

Manuel Tavares

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Again, have you looked at the JavaScript console to see if there are any errors?

The Acrobat JavaScript Console (Your best friend for developing Acrobat JavaScript) by Thom ParkerThe code is like you post, it's because i think so it's strange... by logic this should worked!!Like is similar to close. And close only counts in horseshoes and hand grenades. You may also need to check your form field calculation order.

George Kaiser

mtavares
Registered: Apr 14 2011
Posts: 25
how i do that (JavaScript Console )... but i use FormCalc language!

Manuel Tavares