[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Variants' (#rtl)

VarArrayCreate

Create a variant array

Declaration

Source position: variants.pp line 123

function VarArrayCreate(

  const Bounds: array of SizeInt;

  aVarType: tvartype

):Variant;

function VarArrayCreate(

  const Bounds: pvararrayboundarray;

  Dims: SizeInt;

  aVarType: tvartype

):Variant;

Arguments

Bounds

  

Bounds for the array

aVarType

  

Element type

Function result

The new variant array

Arguments

Bounds

  

Bounds for the array

Dims

  

Number of dimensions in array.

aVarType

  

Element type

Description

VarArrayCreate creates a (optionally multidimensional) array with upper,lower bounds specified in Bounds. The number of bounds (in case of a single array) must be even: 2 bounds for every dimension of the array are required. All elements of the array are of the same type. The following examples create a one-dimensional array with 10 elements

VarArrayCreate([0,9],varInteger);
 VarArrayCreate([1,10],varInteger);

The first array is 0-based, the second is 1-based. The following creates a 2-dimensional array:

VarArrayCreate([0,9,0,1],varInteger);
 VarArrayCreate([1,10,1,2],varInteger);

The first array is 0-based, the second is 1-based. Each array consists of an array of 2 elements.

The array can also be specified as a pointer to array of system.tvararraybound records, and a number of dimensions. The above 1-dimensional arrays can be specified as:

var
  B : tvararraybound;
begin
  b.elementcount:=10;
  B.lowbound:=0;
  VarArrayCreate(@B,1,varInteger);
  b.elementcount:=10;
  B.lowbound:=1;
  VarArrayCreate(@B,1,varInteger);

Errors

If an uneven amount of bounds is specified or the operating system failed to create the array, an exception is raised using VarArrayCreateError

See also

VarArrayCreateError

  

Raise an EVariantArrayCreateError error

VarArrayOf

  

Create a variants array of a series of values


Documentation generated on: May 14 2021