Reflection with arrays

BlitzMax Forums/BlitzMax Programming/Reflection with arrays

JoshK(Posted 2011) [#1]
I am setting up some code to load and save program settings I will share when it's finished.

Why can't I retrieve the correct number of dimensions of the array here?
Framework brl.reflection
Import brl.standardio

Type Thing
	Field color:Int[]=[1,2,3]
EndType

Local t:Thing=New Thing

Local typeid:TTypeId=TTypeId.ForObject(t)

Local o:Object
Local otypeid:TTypeId

For Local f:TField=EachIn typeid.enumfields()
	o=f.get(t)
	otypeid=TTypeId.ForObject(o)
	
	Print otypeid.ArrayDimensions(o)+" dimensions"
	
	Select otypeid
	Case IntTypeId
		Print "Int"
	Case ArrayTypeId
		Print "Array"
	Default
		Print "unknown type"
	EndSelect
Next



JoshK(Posted 2011) [#2]
Ah, ArrayLength, not dimensions.


JoshK(Posted 2011) [#3]
And here it is:
http://blitzmax.com/codearcs/codearcs.php?code=2848


slenkar(Posted 2011) [#4]
checked out bruceys serialization mod yet?


Kryzon(Posted 2011) [#5]
Thanks for sharing.


AdamRedwoods(Posted 2011) [#6]
Nice job, this technique could probably be extended to XML (would need to output types).... or even HTML? Blitzmax to HTML 5? Hmmm......