Read/Write Anything with Classes

When using Read/Write Anything with LabVIEW classes, you have several options. If you connect a class wire directly to Write Anything, you’ll end up with hexadecimal data, i.e. no human readability. You’ll also have only one direction of compatibility: new code can read old data, but old code can’t read new data.

To get better results, you need to create explicit class methods for reading and writing, and use the Read/Write Anything VI’s within those methods. [A newer alternative is RobustXML]. There are two basic options. If you want to leave your class cluster unchanged, then your data is probably something like this…

And your write method will need to look something like this…

Every time you change the data in your class, you break your read and write methods but you can fix them pretty easily. A more automatic approach is to put all your data (or at least all the data you want serialized) within a subcluster like this…

So that your write method can just look like this…

Now when you change the contents of the subcluster, there’s no need to change your code.