VarIsArray Function
VarIsArray
returns True if the
Variant
V
is an array, and it
returns False otherwise. A Variant
array has the
varArray
bit set in its
VarType
.
VarIsArray
is a real function.
// Return the sum of all the numbers in a 1D array, or if the
// argument is not an array, return its numeric value.
function Sum(const V: Variant): Variant;
var
I: Integer;
begin
if VarIsArray(V) then
begin
Result := 0.0;
Assert(VarArrayDimCount(V) = 1);
for I := VarArrayLowBound(V, 1) to VarArrayHighBound(V, 1) do
Result := Result + V[I];
end
else
Result := V + 0.0; // Ensure that the result is numeric.
end;
TVarArray Type, TVarArrayBound Type, VarArrayCreate Function, VarArrayDimCount Function, VarArrayHighBound Function, VarArrayLock Function, VarArrayLowBound Function, VarArrayOf Function, VarArrayRedim Procedure, VarArrayRef Function, VarArrayUnlock Function, Variant Type, VarIsArray Function, VarType Function |