Name

ClearAnyProc Variable

Syntax

var ClearAnyProc: Pointer;

procedure ClearAny(var V: Variant);
ClearAnyProc := @ClearAny;

Description

When Delphi is finished using a varAny Variant value, it calls ClearAnyProc to free all memory associated with the opaque varAny value. The default value is a procedure that raises runtime error 16 (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.

// Clear a varAny Variant that is holding a pointer to an Int64 value.
procedure ClearVarInt64(var V: Variant);
var
  Ptr: Pointer;
begin
  if TVarData(V).VType = varAny then
  begin
    Ptr := TVarData(V).VAny;
    TVarData(V).VType := varEmpty;
    FreeMem(Ptr);
  end;
end;
...
ClearAnyProc := @ClearVarInt64;

See Also

ChangeAnyProc Variable, RefAnyProc Variable, TVarData Type, Variant Type
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset