I think I may have a bug using IsA.
Please try this yourself.
The IsA line throws an type mismatch exception in the debugger, but clearly the object is a Xojo.Core.Dictionary according to the debugger.
[code]Function ToString(d as Xojo.Core.Dictionary, level as integer=0) As String
dim s as string=""
dim tabs as string=""
dim i as integer
dim entry as xojo.Core.DictionaryEntry
for i=0 to level-1
tabs = tabs + chr(9)
next
// Type Mismatch Exception Expected Object but got Int64
For Each entry In d
if entry.Value isa Xojo.Core.Dictionary then
s=s+ToString(entry.Value, level+1)
else
s = s + tabs + entry.Key + “=” + entry.Value + EndOfLine.UNIX
end if
Next
I can only reproduce your results if entry.Value contains something other than an object, for example, an Auto().
Try it this way instead:
if Xojo.Introspection.GetType( entry.Value ) = GetTypeInfo( Xojo.Core.Dictionary ) then...
BTW, it looks like you are using level only for your tabs, so consider passing in the tabs directly:
s = s + ToString( entry.Value, tabs + Chr( 9 ) )
Also, if your Dictionary is very big, I’d expect this to get very slow. You’re better off building a string array that you can join at the end of the process.
How do I know if Value can be expressed as a string?
Must I handle every data type?
right now the s = s + tabs + entry.Key + “=” + entry.Value + EndOfLine.UNIX is throwing an exception because Value isn’t a string.