Can a boolean be set up to find the max value?
/*
@17537118
aFields : an array of the field names to use for the calculation
bIgnoreBlanks : a boolean that tells the function whether or not to ignore blank fields
bIgnoreZeros : a boolean that tells the function whether or not to ignore zero values
*/
function calcMax(fields, ignoreBlanks, ignoreZeros) {
var total = 0;
var n = 0;
for (var i in fields) {
var f = this.getField(fields);
if (f==null) {
console.println("Error! Can't locate a field called: " + fields);
continue;
}
if (f.valueAsString=="" && ignoreBlanks) continue;
var v = Number(f.valueAsString);
if (isNaN(v)) continue;
if (v==0 && ignoreZeros) continue;
total+=v;
n++;
}
if (n==0) event.value = "";
else event.value = total;
}
calcMax(["DT1Moisture Content 01 pcf","DT1Moisture Content 01 pcf_2"], true,true);
I have tried to make this one work, but I am not getting the correct answer.
