Hello all. I've made progress with the reflection examples you guys provided last time I was stuck, but now I'm running into a new problem.
Let's say I have a function that creates a new object from a string containing a type name, like this:
That works fine, but there's a catch: the object returned is an "object" type. Let's say I need a "Tentity" type that I created, and I use the above function to retrieve it from a text file, and I put it in a list.
As soon as I try to access a field in it (like the field "name", that belongs to the Tentity type) the compiler complains, saying it can't find it. In other words, if I create a "Tentity" type directly, I can access its fields just fine, but if I create it using the above function, the compiler doesn't seem to understand that it is a "Tentity" type (or whatever type), not an "object" type
If that's not clear I can post the entire code, but it's quite long.
Thanks in advance!
Leo.
Let's say I have a function that creates a new object from a string containing a type name, like this:
Function CreateNew:Object(ObjType:String) 'Creates a new object based on a string containing the desired Type Local id:TTypeId = TTypeId.ForName(ObjType) If id Local Obj:Object = id.NewObject() Return Obj Else Return Null Print ("Object type " + ObjType + " is not recognized") EndIf End Function
That works fine, but there's a catch: the object returned is an "object" type. Let's say I need a "Tentity" type that I created, and I use the above function to retrieve it from a text file, and I put it in a list.
As soon as I try to access a field in it (like the field "name", that belongs to the Tentity type) the compiler complains, saying it can't find it. In other words, if I create a "Tentity" type directly, I can access its fields just fine, but if I create it using the above function, the compiler doesn't seem to understand that it is a "Tentity" type (or whatever type), not an "object" type
If that's not clear I can post the entire code, but it's quite long.
Thanks in advance!
Leo.