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

Count

puppygirl39
Registered: Sep 22 2008
Posts: 12

I am using the following code in the PerformanceScore Field
avg(Page2.Score1, Page2.Score2, Page2.Score3, Page2.Score4, Page2.Score5)
which works fine if everybody has 5 scores but if the employee only has 3 scores it should divide the total score by 3 and not by 5.

I am thinking I can do something like this but got no where

var Perfcount

Perfcount = Count(PerfCount)
{
if Page2.Score1 == 0 then else 1
else if
if Page2.Score2 == 0 then else 1
else if
if Page2.Score3 == 0 then else 1
else if
if Page2.Score4 == 0 then else 1
else if
if Page2.Score5 == 0 then else 1
end if
}

(PerformanceScore \ count)*.60

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Have you looked at the "Scripting Reference" under LiveCycle Designer's "Help" menu option, It will provide you with the syntax for many of the statements you are trying to code.

Are you getting any error messages?

var PerformanceScore = Sum(Page2.Score1, Page2.Score2, Page2.Score3, Page2.Score4, Page2.Score5)

var Perfcount = 0
if(Page2.Score1 ne 0) then
Perfcount = 1 + Perfcount
endif
if(Page2.Score2 ne 0) then
Perfcount++
endif
if(Page2.Score3 ne 0) then
Perfcount++
endif
if(Page2.Score4 ne 0) then
Perfcount++
endif
if(Page2.Score5 ne 0) then
Perfcount++
endifif(Perfcount ne 0) then
(PerformanceScore / Perfcount )* 0.60
else
null
endif

George Kaiser

puppygirl39
Registered: Sep 22 2008
Posts: 12
I did search on the Scripting Reference under help but could not find it :-( problem was I was searching for it in the right context. I changed the code with the real names of the form and I am getting the following error

Script failed (language is formcalc; context is xfa[0].form[0].PerformanceForm[0].Page11_overall[0].PerfGoalAvgScore[0])
Script =...
Error:syntax error near token 'endif' on line 12, column5


The codes is in the calculate event of the PerfGoalAvgScore Field. This is how I have it

var PerformanceScore = Sum(Page2_Goals.Perf1Rate, Page2_Goals.Perf2Rate, Page3_Goals.Perf3Rate, Page3_Goals.Perf4Rate, Page4_Goals.Perf5Rate)

var Perfcount = 0

if(Page2_Goals.Perf1Rate ne 0) then
Perfcount = 1 + Perfcount
endif
if(Page2_Goals.Perf2Rate ne 0) then
Perfcount++
endif
if(Page2_Goals.Perf3Rate ne 0) then
Perfcount++
endif
if(Page2_Goals.Perf4Rate ne 0) then
Perfcount++
endif
if(Page2_Goals.Perf5Rate ne 0) then
Perfcount++
endif


if(Perfcount ne 0) then
(PerformanceScore / Perfcount )
else
null
endif


I can not thank you enough for helping me!!!