Name
ClearAnyProc Variable
Syntax
var ClearAnyProc: Pointer; procedureClearAny
(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 |
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.