Name

RefAnyProc Variable

Syntax

var RefAnyProc: Pointer;

procedure RefAny(var V: Variant);
RefAnyProc := @RefAny;

Description

The RefAnyProc variable points to a procedure that creates a reference to a varAny Variant. If you must maintain a reference count, RefAny increments the reference count. If each varAny keeps a unique copy, you can make a copy of the varAny data in the RefAnyProc procedure. The default value is a procedure that raises runtime error 15 (EVariantError).

Tips and Tricks

The CorbaObj unit sets this variable to point to a procedure that supports CORBA’s Any type. If you are not using CORBA, you can use varAny values for your own purposes.

Example

See the ChangeAnyProc variable for an explanation of this example.

// Each varAny Int64 value has its own unique Int64 value.
// When Delphi makes a reference, it sets V to a copy of
// the original. This procedure gives V a unique Int64 value.
procedure RefVarInt64(var V: Variant);
var
  Value: Int64;
begin
  if TVarData(V).VType = varAny then
  begin
    Value := PInt64(TVarData(V).VAny)^;
    SetVarInt64(V, Value);
  end;
end;
...
RefAnyProc := @RefVarInt64;

See Also

ChangeAnyProc Variable, ClearAnyProc Variable, TVarData Type, Variant Type

Get Delphi in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.