Anyone know if this is possible? I'm trying to write a load and save system for my types. I got the save part to work, but the loading is giving me some issues. My goal is to make the system complete generic so it will save any type you throw at it.
here's my save function...
Here's my non working save function...
This is a string in my file that says "new agent". "agent" is the name of my type. I threw the "new" in there so it knew it was creating a new type and not assigning a field.
I'm probably not using the "Object" part incorrectly. Anyone know how to resolve this?
here's my save function...
Function saveType(instance:Object,file:TStream) Local id:TTypeId=TTypeId.ForObject(instance) Local fList:TList = id.EnumFields() WriteLine file,"new " + id.name() For Local myField:TField = EachIn fList WriteLine file,myField.name() + " " + myField.getString(instance) Next End Function
Here's my non working save function...
This is a string in my file that says "new agent". "agent" is the name of my type. I threw the "new" in there so it knew it was creating a new type and not assigning a field.
Function loadTypes(filename:String) Local file:TStream = ReadFile(filename) Local myLine:String myLine = ReadLine(file) Local myCom:String[] = myLine.split(" ") Select myCom[0] Case "new" Local id:TTypeId=TTypeId.ForName(myCom[1]) Local myItem:Object = id.newObject() End Select CloseFile file End Function
I'm probably not using the "Object" part incorrectly. Anyone know how to resolve this?