Name

VarArrayRedim Procedure

Syntax

procedure VarArrayRedim(var V: Variant; HighBound: Integer);

Description

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.

Tips and Tricks

  • 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.

Example

// 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;

See Also

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
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset