Is Variant a FolderItem

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?

if v.Type = Variant.TypeObject and v isa FolderItem [ or Dictionary, etc ] then
  ...

a simple

if v isa FolderItem then

is enough as Variants are always objects, so isa will work just fine.

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.

[quote=471427:@Christian Schmitz]a simple

if v isa FolderItem then

is enough as Variants are always objects, so isa will work just fine.[/quote]

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!

-karen

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.

[quote=471434:@Christian Schmitz]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.[/quote]

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.

-Karen

[quote=471425:@Kem Tekinay] if v.Type = Variant.TypeObject and v isa FolderItem [ or Dictionary, etc ] then ... [/quote]
This did the trick, quite nicely, thank you.