Count(Values: Array): Integer;
Values. Array.
The Count property returns the number of non-empty elements in the array.
To get the number of empty array elements, use the IStatistics.CountBlank method.
To execute the example add links to the MathFin, Stat system assemblies.
Sub UserProc;
Var
mathF: Math;
Ar: Array Of Double;
count, i: Integer;
value: Double;
st: Statistics;
Begin
// Create array with random number of elements
mathF := New Math.Create;
count := mathF.RandBetweenI(1, 100);
Ar := New Double[count];
// Populate array with values that are greater than 0.5
For i := 1 To count - 1 Do
value := mathF.Rand;
If value > 0.5 Then
Ar[i] := value;
Else
Ar[i] := Double.Nan;
End If;
End For;
// Display information about created array in the console window
st := New Statistics.Create;
Debug.WriteLine("Total number of elements in array: " + count.ToString);
Debug.WriteLine("Number of non-empty elements in array: " + st.Count(Ar).ToString);
Debug.WriteLine("Number of empty elements in array: " + st.CountBlank(Ar).ToString);
End Sub UserProc;
After executing the example the console window displays information about the array: total number of elements, the number of non-empty elements and the number of empty elements.
See also: