One of my not so well kept secrets is that I really love to use OpenG’s free software libraries when I write software (using LabVIEW, of course). Yes, I’m a little biased (OK, a lot biased) because I have had a significant role in the development of these tools. That aside, I’m pretty sure that most people would agree with me that these are really great tools.
On a regular basis, I’m going to be providing, here on Thinking in G, glimpses at some of libraries and VIs that I could not live without — the tools that I use, every day, in every LabVIEW project (literally). I’ll try to explain why they are so useful and show some examples of how to use them.
For this first article, let’s start out by looking at my all time favorite OpenG library, the Variant Configuration File VIs. But, first, in order to use these VIs, you need to understand what a Configuration File (a.k.a, “INI” file) is. Quickly, go take a look at the wikipedia definition of “INI File”. Done, yet? OK, let’s move on.
Basically, the Variant Configuration File VIs (shown to the right) accept a variant input and will write the variant data to an INI file, or read the INI file and write the data to a variant. To use these VIs, you don’t really need to understand Variants. All you need to know about them is that they are a “magic” data type that that allows you to wire up any other data type to it — this means that you can pass anything into the Variant Configuration File VIs and it will get written to or read from an INI file. I bet you’re thinking, “Why didn’t you just say that in the first place, Jim. That’s amazing!” Yes, it is amazing and that’s why these VIs are my absolute favorite OpenG library. OK, now let’s take a look at how to use these VIs.
After installing VI Package Manager (VIPM) and downloading and installing the Variant Configuration File VIs (the oglib_variantconfig package from within VIPM ), you will find the Variant Configuration File VIs palette in the Functions palette under the OpenG submenu. (See here for a quick guide on how to install OpenG on VIPM.)
For writing data to an INI file, use Write Section Cluster, as shown below.
For reading data from an INI file, use Read Section Cluster, as shown below. Reading the data from file requires that we pass the type into Read Section Cluster. The output is a variant, which we must convert back into our cluster using the Variant To Data function.
As you can see, these VIs use the names of each of the cluster elements as key names in the INI file. This saves you tons of time, as compared to reading and writing individual keys, the old fashioned way. It’s easy to see why these VIs are at the top of the list of OpenG VIs that I couldn’t live without.
[Update] For a list of all the articles in this series, click here.