From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unbundle by Name: shows extra elements; How to unbundle by name?

I am trying to create a little subVI that takes in a file path (say C:\test\test1\test.txt) and gives the option to select any number of elements in the path (C, test, test1, test.txt) by name.

The path can have any number of subfolders with any names.

My thought process was to use Path to Array function, then Array to Cluster, then use Unbundle by Name.

 

Two questions:

 

1. When I connect the output of Array to Cluster to Unbundle by Name I see 2x as many elements in the cluster than I should. Why is that?

2. Is there a way to unbundle the cluster by name using the actual lable of the element as opposed to array of string[0], array of string[1], etc.? See the attached picture.

I tried to create a property node for the array and the change the actual label of each element using the text property, but apparently it is not allowed to change

the label of an element using property nodes.

 

Is there an alternative way to do what I am trying to do?

 

Untitled.jpg

0 Kudos
Message 1 of 7
(4,206 Views)

You actually see 9  if you right click array to bundle you will be able to change the number of elements to build into a bundle.  9 was chosen as the default because it is the most likly value to be wrong and developers would remember to set it after just one little mistake.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 7
(4,197 Views)

Thanks Jeff.

 

But the size need to automatically adjust to the number of elements in the array. For this example I can set it to 4, but in my application, the path could have any number of subfolders.

Anyway, my primary problem is still to unbundle by name without manually labeling the elements in the cluster.

0 Kudos
Message 3 of 7
(4,190 Views)

The flexibility that you are looking for is what arrays are there for.

You will not get that feature in a cluster, just like you will not get it with a struct in C.

 

0 Kudos
Message 4 of 7
(4,185 Views)

  I wouldn't use the cluster for this.  Wire the array into a listbox control (set selection mode to 1 or more).  This way, the listbox will be populated with the elements from your array and you don't have to care about how many items there are.

 

Use property node Value of the listbox to get an array of the item entries selected by the user (a for loop with index array will let you retreive the names from the array).

 

 

Message 5 of 7
(4,184 Views)

In addition to what Jeff said, Unbundle by Name only works with clusters which have named elements.  That is, a control, indicator, or constant ahs been created with non-empty labels for each element and a wire from that cluster type is connected to the Unbundle by Name terminal.  You do not have a cluster of labeled elements and what you want involves the values, not the labels.

 

I do not know of any way to get values from strings to something you can read on a block diagram easily.  You could make a little VI like your image but without the cluster stuff. Run it. Then change the path array to a constant.  Expand the array until you can see the text elements. Drag the constant to the original VI.

 

Lynn

0 Kudos
Message 6 of 7
(4,182 Views)

Thanks guys.

 

I will try some of the suggestions, once I make it work, I'll mark it as a solution.

0 Kudos
Message 7 of 7
(4,164 Views)