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 Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
0 Kudos
JiriVejrazka

For loop iterating on cluster

Quite frequently, I encounter a need to do something repetitive on clusters, which have identical elements. Sometimes, I use "Cluster to array" and then "Array to cluster" vi's, like in the example below:

For loop on cluster.PNG

 

Instead of doing this, I would like to use a kind of "For loop", which would be able to operate directly on clusters with identical elements. The loop would iterate already during the compilation (generating repetitive code for each cluster element).

 

Perhaps, the standard For loop connector might have something like an option "Iterate over cluster elements".

12 Comments
drjdpowell
Trusted Enthusiast

Kudoed the other idea, though it is not a complete duplicate as it doesn't include the concept of getting the cluster back from the loop's output tunnel (which is where the real value comes).

drjdpowell
Trusted Enthusiast

Also, the point of the idea is better understood when the cluster isn't "Servo1", "Servo2", "Servo3"; it's "Source Azimuth", "Source Elevation", "Camera Height", etc., a set of meaningfully-named things that you mostly unbundle by name ("Change Camera Height"), but also sometimes need to act on as a group ("Read Servo Positions").

 

Using Array-to-Cluster will currently work for this, but is very work-intensive in handling changes to the number of cluster elements.  An array also works, but loses the benefits of unbundle-by-name.