VarArrayCreate function
Creates a variant array.
function VarArrayCreate(const Bounds: array of Integer; VarType: TVarType): Variant;
VarArrayOf function
Creates and fills a one-dimensional variant array.
function VarArrayOf(const Values: array of Variant): Variant;
Example:
var
A: Variant;
begin
A := VarArrayCreate([0, 4], varVariant);
A[0] := 1;
A[1] := 1234.5678;
A[2] := 'Hello world';
A[3] := True;
A[4] := VarArrayOf([1, 10, 100, 1000]);
WriteLn(A[2]); { Hello world }
WriteLn(A[4][2]); { 100 }
end;
Locks a variant array and returns a pointer to the data.
function VarArrayLock(const A: Variant): Pointer;
type
PArrayData = ^TArrayData;
TArrayData = array[0..9, 1..3] of Integer;
var
A: Variant;
P: PArrayData;
I, J: Integer;
begin
A := VarArrayCreate([1, 3, 0, 9], varInteger);
P := VarArrayLock(A);
try
for I := 0 to 9 do
for J := 1 to 3 do
P^[I, J] := J * 10 + I;
finally
VarArrayUnlock(A);
end;
WriteLn(A[1, 9]); { 19 }
WriteLn(A[3, 4]); { 34 }
end;