This is the third 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 a couple really great functions: “String to 1D Array” and “1D Array to String“. These two little VIs are used to convert between a string and a 1D array of strings based on a delimiter (see wikipedia definition of “delimiter”) that you specify. Let’s take a look at a simple example of these VIs in action.
Let’s say that we start with a string “one, two, three, four” and we want to extract each of the words that are separated (delimited) using a comma followed by a space character (“, “). We can use “String to 1D Array” to convert our input string into an 1D array, containing the words as elements, as shown below.
If we want to convert our array of strings into a single string with a delimiter to separate each of the elements in the input 1D array of string, we can use “1D Array to String” to accomplish this task, as shown below.
You’ll certainly find lots of uses for these two VIs, as you’re programming your applications. The above examples are just a simple glimpse of the basic functionality.
If you want to give these VIs a try, you can obtain them using VI Package Manager (VIPM). Simply select the OpenG String Library (the oglib_string package from within VIPM), you will find the OpenG String Tools palette in the Functions palette under the OpenG submenu. (See here for a quick guide on how to install OpenG on VIPM.)