[Gambas-user] Creating a Variant[] on the fly

Bruce Bruen bbruen at ...2308...
Mon Apr 18 12:28:52 CEST 2011


On Monday, April 18, 2011 06:00:14 PM Benoît Minisini wrote:
> > Nevermind, I got around it by
> > 
> > DIM vArray as New Variant[]
> > 
> > 	varray=["Cardinalities",.LocalCardinality,.TargetCardinality]
> > 	csvRelData.Add(varray,"Cardinalities")
> > 	varray=["Transpose",.LocalSliceMethod,.TargetSliceMethod]
> > 	csvRelData.Add(varray,"Transpose"]
> > 	etc
> > 
> > which only doubles the size of the code.
> > 
> > But it would be nice if there was some way to cast an array as Variant[]
> > 
> > :-)
> 
> Normally that casting is automatic in Gambas 3. Which version do you use?

Still on Gambas 2, frantically awaiting!

gb2 correctly (according to the docs) internally casts the inline array to the 
type of the first element.

However, because my control handles a lot of stuff of different types (sometimes 
I am adding an object that has its own rendering method (e.g. SliceMethod has 
a "StrRep" method that converts a geo-thingo (magnetometers) into a  string) I 
need (read "want") to pass the array specifically as a Variant[].

The inline array, when I coerce it into a Variant[] works beautifully.  My 
desire is just a matter of reducing the calling code to its' simplest form (to 
lower the incidence of our coding errors!)

So I will restate my desire as :
It would be nice to be able to cast an inline array into a Variant[] rather 
than have it automatically be cast according to the first element.

-- 
best regards
Bruce Bruen




More information about the User mailing list