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

Making formcalc formulas not display zero as a result

actay
Registered: May 12 2009
Posts: 13
Answered

I'm fairly new to Adobe LiveCycle and am looking for some assistance with formcalc.

I am using the following formcalc formula to calculate cubic feet:
Round(Length[0]*Width[0]*Height[0]/1728,2)
When the answer is zero, I'd like the CubicFeet[0] field to remain blank. Right now the field is constantly displaying a 0 until I enter values into the length, width, or height fields.

I am also calculating the density by dividing weight by cubic feet. In order to avoid a divide by zero error, I am using the following formcalc formula:

if ((Weight[0]>"0") & (CubicFeet[0]>"0")) then
	round(Weight[0]/CubicFeet[0],2)
endif

I'd also like the Density[0] field to remain blank if the answer is 0.

I'd greatly appreciate any help I could get with this as it's making me very frustrated!

Thank you!

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
I would compute the density and then make a decision as to whether to display the result or not.
// define a variable for computed densityvar fDensity = 0// compute density if cubic feet not zeroif (CubicFeet > 0) then// compute densityfDensity = Round(Weight / CubicFeet, 2)endif// display null if computed density is zeroif( fDensity == 0) thennullelse// display the computed resultfDensityendif

George Kaiser

actay
Registered: May 12 2009
Posts: 13
Thanks for the reply, gkaiseril. When I copy the code to the Density field, Density displays as 1 regardless of whether or not there is information entered into Weight or CubicFeet. What am I doing wrong?
actay
Registered: May 12 2009
Posts: 13
I don't know why this wasn't clicking yesterday, but I went with the following for the CubicFeet.

if (Length>0 & Width>0 & Height>0) thenRound(Length*Width*Height/1728,2)elsenullendif

I went with the below for Density.

if (Weight>0 & CubicFeet>0) thenround(Weight/CubicFeet,2)elsenullendif
jonom
Registered: Jan 31 2008
Posts: 133
If you set the Display Pattern for the calculated field to Allow Zero (or put "zero{}" in the Pattern box) it won't display a zero.

Click on the Patterns button on the Object palette when you have the field selected to get there.
actay
Registered: May 12 2009
Posts: 13
Thanks for the tip jonom, that is a very simple thing to do.