10-13-2005 05:08 AM
10-13-2005 08:02 AM
The methods I have used for storing preferences/configs are:
1. Text files - easy to use, human readable but order matters
2.ini files - easy to use(not cumbersome once you get used to them), order in not important, extensible, human readable. Labview uses these files often
3. Registry keys - higher learning curve, can cause big problems if not used properly (this is a little bit of a taboo topic and scares off many novice users) big advantage is that the file is location independent and somewhat hidden from the user (could be a pro or con depending on the application).
4. XML files - harder to use but there are a few flatten to XML functions. This is platform and application independent, well structured extensible and a good option but requires a lot of planning to do right.
I prefer using .ini files usually. Hope this helps.
Paul
10-13-2005 08:51 AM
10-24-2005 03:03 PM
I have also begun to use XML extensively, and agree that only needing to change the type def, and not the VI, makes maintenance a breeze. My only issue now is this: XML files can't be incrementally updated to allow for changes to the type def. i.e. If I change the type def, the existing XML file is no longer valid, and can't really be read at all, unless I go in and manually edit it in a text editor. This means that configuration data for a previous release of my application can sometimes be totally lost when the app is upgraded. Has anyone found a way around this?
Jaegen
10-24-2005 04:04 PM
10-25-2005 09:25 AM
Jaegen,
Yes changing the data structure will pose a problem with the XML representation of the data (since the XML is a serialized version of the data structure) but there is a simple workaround that I have used, versioning your data. That is place a version tag in the XML file, here you can use a case structure on the read vi to read data in a different format, as long an the data structure can be converted in code, like unbundled a complex data type and rebundeling it to a new type. Even a simple typecast will do sometimes.
Paul
10-25-2005 11:15 AM
10-25-2005 12:20 PM
10-26-2005 08:28 AM
I usually use HDF5 for this purpose. It is a binary, hierarchical file API which produces completely cross platform files and generic browsers are freely available. A simple LabVIEW version is available from the article Can I Edit and Create Hierarchical Data Format (HDF5) files in LabVIEW?. Original source code, documentation, and file browser are available from the HDF5 website.
HDF5 does require some effort. There is no easy "flatten large data structure to string" method. However, HDF5 files are extensible; you can add to them at will, and they are fast. In addition, you can put a lot more than simple variables in them. For example, the NI-SCOPE Soft Front Panel (SFP) uses HDF5 for its configuration file. If the user has imported some waveforms for comparison into the SFP, when the configuration is saved, the user has the option to save the waveforms as well. If done, the waveforms are saved in the same file in binary, compressed form using the NI-HWS standard formatting (NI-HWS is HDF5 based). A link is put in the configuration pointing to the waveforms. The waveforms also contain a link back to the configuration, so that if a user imports the waveform into the SFP and wishes to reset the SFP to the configuration present when the waveform was taken, this can easily be done. Those who have been paying attention will notice the circular reference. This is possible because HDF5 is actually a directed graph, not a hierarchy.
Some generic tips for configuration files, some of which have been mentioned