Reflection and name().

BlitzMax Forums/BlitzMax Beginners Area/Reflection and name().

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

How can you use the type name returned from ttypeid name() method to cast an object back to it's original type?
SuperStrict
Type ttest
   Field x:Int
End Type

Local test1:ttest=New ttest
test1.x=5
Local test2:Object=Object(test1)


Local id:TTypeId=TTypeId.ForObject(test2)
Local typename:String=id.name()
Print typename
'Print typename(test2).x

Obviously this is much simplified but I have my original type name in a string variable called 'typename'.
Unfortunately, I can't use that to cast my original object. If you uncomment the print statement you get message
'Expression of string cannot be invoked'
Am I missing something?