Name

VarArrayCreate Function

Syntax

function VarArrayCreate(const Bounds: array of Integer;
    VarType: Integer): Variant;

Description

The VarArrayCreate function creates a Variant array. The first argument specifies the number of dimensions and the bounds for each dimension. The second argument is the Variant type of each array element.

The array bounds are specified as pairs of integers: the lower and upper bounds of each dimension. The array can have up to 64 dimensions. If you try to create an invalid array, VarArrayCreate reports runtime error 24 (EVariantError).

VarArrayCreate is a real function.

Tips and Tricks

  • Create a heterogeneous array by specifying varVariant as the element type. That way, each element of the array can be of any Variant type.

  • You cannot create an array of varEmpty or varNull types.

Example

// Return a Variant array of 12 random numbers.
function RandomDozen: Variant;
var
  I: Integer;
begin
  Result := VarArrayCreate([1, 12], varDouble);
  for I := VarArrayLowBound(Result) to VarArrayHighBound(Result) do
    Result[I] := Random;
end;

See Also

TVarArray Type, TVarArrayBound Type, VarArrayDimCount Function, VarArrayHighBound Function, VarArrayLock Function, VarArrayLowBound Function, VarArrayOf Function, VarArrayRedim Procedure, 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