So I have figured out how to check for most variant types, but folder items always seem to come up as Object, the same goes for Dictionary and various other items. I am wondering how I would I go about determining if a variant contains a folderitem?
For some reason I was under the impression that this would cause an exception, but testing shows otherwise.
Edit: ... would cause an exception if the variant held a non-object like integer or boolean...
when variant contains an integer, it references a VariantInteger object, which you won't see in Xojo.
So variant is always an object and if you use VarType, it checks for the various known types and returns the right number for the internal variant classes. For all other it returns 9.
@ChristianSchmitz a simpleif v isa FolderItem then
is enough as Variants are always objects, so isa will work just fine.
Interesting I always do:
Variant.Objectvalue IsA ClassName
Because I always thought of the variant itself being an object that contains an item of any type, and I wanted to make sure I was comparing the right things!
@ChristianSchmitz As far as I know Objectvalue is a simple function to return just the variant itself, just with object as data type.
I prefer variant as I don't need to cast explicitly.
I always thought of Variant.Object Vale as analogous for example to variant.IntegerValue...
In other words that all the Variant.*Value methods return what the variant contains as that specific type if possible.