Inconsistent Exception

Hi there,

I’m getting a TypeMismatchException inconsistently with the following lines. I don’t suppose anyone has an idea as to why this exception only occurs SOME of the time? I should say, in this example, the dictEvent var is the same data every time (saved state from a player turn).

dim aIP as Auto = dictEvent.Value("InitialPositions") dim dictIP() as xojo.Core.Dictionary = dictEvent.Value("InitialPositions")

It’s the second line that occasionally (why only occasionally?! argh!) throws a TypeMismatchException. If I exit and run the project again, it will happily assign dictIP() to dictEvent.Value(“InitialPositions”).

I attempted to try and handle the occasional exception with

[code] dim aIP() as Auto = dictEvent.Value(“InitialPositions”)
dim dictIP() as xojo.Core.Dictionary

for each d as xojo.Core.Dictionary in aIP
dictIP.Append(d)
next[/code]

In that case, aIP()=dictEvent.Value(“InitialPositions”) throws an exception. Bit lost as to why the exception isn’t occurring 100% of the time!

Oh yeah, should probably say, dictEvent.Value(“InitialPositions”) is most definitely an array of dictionaries.

It’s a bit annoying not knowing why

  dim dictIP() as xojo.Core.Dictionary = dictEvent.Value("InitialPositions")

only occasionally throws an exception.

But so far this:

dim aIP as Auto = dictEvent.Value("InitialPositions") dim dictIP() as xojo.Core.Dictionary = aIP
seems to avoid throwing exceptions.

what exactly are you attempting to do…

 dim aIP as Auto = dictEvent.Value("InitialPositions")

This creates a scalar value (not an array) that is the value of one entry in the dictionary “dictEvent”

  dim dictIP() as xojo.Core.Dictionary = dictEvent.Value("InitialPositions")

This is attempting to create an entire DICTIONARY from ONE value, which might work if that one value is in itself another dictionary… but you haven’t indicated if that is true or not