04-10-2020 11:06 AM
Hello All,
I have a requirement of saving my LabVIEW Object Array to a file.
Here I need to save only the LabVIEW Class Data. I have a Parent class called Device, and under that I have different Child Devices. Initially I thought of saving it as a binary file and its working fine. But if I modify any class ,like add or delete the Property of method of it, The file I saved is not opening .I understand its because of data type mismatch.
Can anyone suggest me what is best method of saving Class array. The array includes the parent class and child classes also.I will be using some of the parent properties in child classes .Also child class is having its own properties too.
I thought of using XML or Ini file to Save the Class Data. Section as Class name and Key is the property and Data is the value of the property.
Can programmatic get all the properties of a class and value in it (including the parent class property used ).
Thank you
Vipinraj KK
Solved! Go to Solution.
04-10-2020 11:48 AM
If you use the built-in LabVIEW flatten to XML and unflatten from XML nodes, it's all done automatically. It's even smart enough to be able to load old versions of the class data somewhat well. It does an even better job at loading old versions if you use the techniques listed in this article on preserving class data.
04-10-2020 12:03 PM
04-11-2020 11:52 AM
What error do you receive? Loading old versions of class data should work also from binary file. Adding or removing methods will not change the class flattend private data so it has no reason not to load. Do you have a class holding your array of objects or you build the array before saving? I would create such a class with methods for saving and loading from file. Also, all the classes in the file must be already in memory when loading.
04-11-2020 01:17 PM
Hi,
Thanks for your reply
I have a class called device.lvclass and child classes are NI Cards , like PXI6226.lvclass,PXI6259.lvclass and etc.
Inside Parent class (Device.lvclass) class I have property called "device array", That is created using LabVIEW base object and I m inserting all the child classes inside that parent Property. I save that device object to a binary file.
After modifying any if the classes(Parent or child) if i try to read the old file , its showing the file corrupted error.