This is the ninth article of “The OpenG VIs that I couldn’t live without“, a series of articles showing some of my favorite OpenG VIs. In this article, I’m going to show you a great hidden feature of the OpenG File Tools library: relative path inputs to file constants. You might have noticed that all of the file constants on OpenG File Tools File Constants subpalette have a “Relative Path (.)” input, and you might also be wondering what the heck this is for. For example, here are the NI and OpenG versions of the Temporary Directory function.
The “Relative path (.)” input of the OpenG version allows you to avoid some of the extra code required to build a path, relative to the constant (and, if you leave that input unwired, then the function simply outputs the path, in the same way as the NI function). For example, let’s look at a common use case, implemented with the NI version of Temporary Directory.
Now, let’s look at the equivalent code, using the OpenG version.
That’s one less node and one less wire. It’s not much, but it adds up!
If you want to give these OpenG file constant VIs a try, you can obtain them using VI Package Manager (VIPM). Simply select the OpenG File Library (the oglib_file package from within VIPM), you will find the OpenG File Tools palette (and File Constants subpalette) in the Functions palette under the OpenG submenu. (See here for a quick guide on how to install OpenG on VIPM.)