Dictionary Key Help

Hey all,

I’ve got a Xojo.Core.Dictionary that gets several values that are the older framework dictionaries. The key values for these dictionaries are integers. I have one more key-value pair that are both strings.

I’m trying to do code like this:

For Each Entry as Xojo.Core.DIctionaryEntry in CurrentLayout

    If Entry.Value isA Dictionary Then

      ///
   End If
Next

But that doesn’t work. When it hits the string value, I get an exception that it was expecting an object but got string.

Similarly, if I try this:

For Each Entry as Xojo.Core.Dictionary.Entry in CurrentLayout

   If Entry.Key = "Name" Then
      Continue
   End If

   /////

Next

If get an exception that it expected integer but got string. I can see how that happens when Entry.Key is an integer and you try to use it in an expression with a string.

So I’m kind of at a loss here. It seems like both of these items should work but they aren’t. I even tried in the first example to set up a separate variable of Type Auto and checking it’s type via IsA but I got the same error.

So I’m stuck. Not sure what I am doing wrong…

Use the Introspection through the new framework:

if Xojo.Introspection.GetType( Entry.Value ) = GetTypeInfo( Dictionary ) then ...

OK. I"m curious why IsA does not work. That always seemed very simple…

IsA does not work on intrinsic types, only objects.

Your other option is to convert the value to a Variant and use Variant.Type, but at that point, you should just use the classic Dictionary.

I just discovered that about IsA. I tried to do “IsA string”

Thanks.