March 2000
Intermediate to advanced
576 pages
18h 13m
English
VarArrayRedim Procedure
procedure VarArrayRedim(var V: Variant; HighBound: Integer);
VarArrayRedim resizes the rightmost dimension of
the Variant array V. The upper
bound of the highest dimension is changed to
HighBound.
VarArrayRedim is not a real function.
You cannot resize a Variant array while the array
is locked.
Resizing an array preserves as many array elements as possible. If
the array grows larger, the new elements are initialized to zero if
the array element type is a numeric type,
Unassigned for varVariant
elements, and an empty string for string
elements.
You cannot change the size of an array reference (that is, the result
of calling VarArrayRef). You must pass the actual
array to the VarArrayRedim procedure.
// Read numbers from the user into a growing array.
// This function is inefficient, but a good demonstration
// of VarArrayRedim.
function GetArray: Variant;
var
Number: Integer;
begin
Result := VarArrayCreate([1, 0], varInteger);
while not Eof do
begin
ReadLn(Number);
VarArrayRedim(Result, VarArrayHighBound(Result, 1) + 1);
Result[VarArrayHighBound(Result, 1)] := Number;
end;
end;| TVarArray Type, TVarArrayBound Type, VarArrayCreate Function, VarArrayDimCount Function, VarArrayHighBound Function, VarArrayLock Function, VarArrayLowBound Function, VarArrayOf Function, VarArrayRef Function, VarArrayUnlock Function, Variant Type, VarIsArray Function, VarType Function |
Read now
Unlock full access