Write Array Of Objects

How can I write and read an array of objects to/from a disk file?

If these are objects you created, add ToXML and FromXML methods and use those to turn your objects into strings and back again.

Thanks Kem - I can’t find any documentation on ToXML and FromXML, could you give me an example of how to use these?

These are just method names I am suggesting. Xojo is not going to convert your objects into writeable data for you, so you have to do it yourself. To that end, I am recommending that you write a method called “ToXML” (or ToString, if you prefer). That method will take each of your object’s properties, put it into XML form, then output the XML string. You’d have to write a companion method that takes such a string and fills in the properties with the data it finds within it.

If you’ve never worked with XML, start with XMLDocument in the Language Reference. There is probably an example in the Xojo package too.

Thanks Kem - I will try your suggested method.

I believe VB and possibly the other VS languages have serialize methods that allow the writing of object arrays to a disk file. I am assuming that there is no such equivalent in XOJO - Is that correct?

If there is, I haven’t found it.