what command I can use to count only the fields blank? and what is its syntax?

my program calculates the average of seven rates entered by the user, but i also want to calculate the partial average.
thank you
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
what command I can use to count only the fields blank? and what is its syntax?
Code: Select all
This function return a empty field list:
on mouseup
put getEmptyField()
end mouseup
function getEmptyField
put empty into rEmptyField
put the num of flds into nbF
repeat with i = 1 to nbF
if fld i = empty then
put the short name of fld i & cr after rEmptyField
end if
end repeat
delete char-1 of rEmptyField
return rEmptyField
end getEmptyField
Code: Select all
on mouseup
put getEmptyField("MyGroupName")
end mouseup
function getEmptyField sGroupID
put empty into rEmptyField
put the num of flds of grp sGroupID into nbF
repeat with i = 1 to nbF
if fld i of grp sGroup = empty then
put the short name of fld i of grp sGroupID & cr after rEmptyField
end if
end repeat
delete char-1 of rEmptyField
return rEmptyField
end getEmptyField
Code: Select all
on mouseUp
set the numberFormat to "#.00"
put field "ammissione" into tData1
put field "italiano" into tData2
put field "matematica" into tData3
put field "inglese" into tData4
put field "2a lingua" into tData5
put field "INVALSI" into tData6
put field "orale" into tData7
put (tData1 + tData2 + tData3 + tData4 + tData5 + tData6 + tData7) into tDataSum
if tData1 > 0 then
put 1 into tNum1
end if
if tData2 > 0 then
put 1 into tNum2
end if
if tData3 > 0 then
put 1 into tNum3
end if
if tData4 > 0 then
put 1 into tNum4
end if
if tData5 > 0 then
put 1 into tNum5
end if
if tData6 > 0 then
put 1 into tNum6
end if
if tData7 > 0 then
put 1 into tNum7
end if
put (tNum1 + tNum2 + tNum3 + tNum4 + tNum5 + tNum6 + tNum7) into tNumSum
-- it calculates the partial average
put tDataSum / tNumSum into fld "media"
end mouseUp
Code: Select all
on mouseUp
repeat with y = 1 to the number of flds
if fld y > 0 then
add 1 to divisor
add fld y to numerator
end if
end repeat
answer numerator / divisor
end mouseUp
The more clunky and verbose your coding, the faster you learn. Think how much more raw LC you used to write your handlers than I did. Think of it as working out in a gym. All that effort becomes part of you.My code is prehistoric
"Good judgment comes from experience. Experience comes from bad judgment."dunbarx wrote:The more clunky and verbose your coding, the faster you learn.