Niall_O_Donovan@adobeforums.com wrote:
> I am having difficulty with an if statement to prevent division by zero before the user puts in a value for the "Hours_Direct5" field
>
> if ( Hours_Direct5=0 ) then Fatal_AFR_Direct5=0 else Fatal_AFR_Direct5 = Number_Fatalities_Direct5 * 100000 / Hours_Direct5 endif
>
> For starters it did not like the statement "if ( Hours_Direct5=0 )" so I changed it to "if ( Hours_Direct5<1 )" and set a Default value for Hour_Direct5 as 0. While this works it is not particurarly good, as having a ZERO value for the Hours_Direct5 discourages a user putting in a real value.
>
> Ideally I want the IF statement to return a blank statement " " if the Hours_Direct5 field is either null or zero (i.e. if the user has not put in a value for the hours)
>
> Any help gratefully received, thanks, Niall (a script novice)
Niall,
Try using the following:
if ( Hours_Direct5 == 0)
When you use a single equal sign, you are assigning Hours_Direct5 equal
to zero. When you use a double equal sign, you are testing the two
values to see if they are equal.
Justin Klei
Cardinal Solutions Group
www.cardinalsolutions.com