March 2000
Intermediate to advanced
576 pages
18h 13m
English
VarArrayRef Function
function VarArrayRef(const V: Variant): Variant;
VarArrayRef creates a new
Variant array with the varByRef
bit set in the Variant’s
VarType. The new Variant refers
directly to the array data in V. Any changes to
the dimensions or contents of V are also reflected
in the new array.
VarArrayRef is a real function.
Once you have created the reference, you must take care not to let
the reference outlive the original array. If both
Variants are in the same scope, you are fine, but
do not return the reference array from a function where the original
array is local to the function.
You cannot redimension an array reference.
var
Orig, Ref: Variant;
begin
Orig := VarArrayCreate([1, 10], varInteger);
Ref := VarArrayRef(Orig);
Orig[1] := 42;
WriteLn(Ref[1]); // Writes 42
VarArrayRedim(Orig, 5); // Also affects Ref
WriteLn(VarArrayHighBound(Ref, 1)); // Writes 5
end; // Ref and Orig are cleaned up| TVarArray Type, TVarArrayBound Type, VarArrayCreate Function, VarArrayDimCount Function, VarArrayHighBound Function, VarArrayLock Function, VarArrayLowBound Function, VarArrayOf Function, VarArrayRedim Procedure, VarArrayUnlock Function, Variant Type, VarIsArray Function, VarType Function |
Read now
Unlock full access