Board index » delphi » Variant type conversions if Variant is a pointer to data

Variant type conversions if Variant is a pointer to data

Hi all,

Please help me:
How can I do type conversions with a variant, if I need to use a pointer
to data in the variant, not
the data itself?

I.E:
I am setting a PVariant (PMyVariant) to:
    TVardata(PMyVariant).Vtype:=Vinteger;
    TVardata(PMyVariant).VPointer:=Addr(MyData);

So if I want to get it back I have to say:

Case  TVardata(PMyVariant).Vtype of
  vInteger: GetmyVarback :=  integer(TVardata(PMyVariant).VPointer^);
  vtBoolean : GetaBooleanBack;
  vtChar      :GetACharBack;
  vtExtended : andsoon ....

--
===========================================================================

   Klaus Heerlein                         phone:  ++49 (0)5556 979-387
   Max Planck Institut fr Aeronomie        fax:  ++49 (0)5556 979-240
   Max Planck Str. 2
   D-37191 Katlenburg-Lindau
===========================================================================

 

Re:Variant type conversions if Variant is a pointer to data


Quote
Klaus Heerlein wrote:

> Hi all,

> Please help me:
> How can I do type conversions with a variant, if I need to use a pointer
> to data in the variant, not
> the data itself?

No solution.

The problem is less to get Pointers to some things. But did you consider that
Variants disappear if you leave the scope they are defined in? If you then
have a Pointer into the Variant internal structure, that Pointer then points
to garbage.

Give us some more information about what you intend to do. I'm sur we find a
solution.

-Michael

Other Threads