LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to reference cluster by their string name

I have a program that contains 6 clusters of the same structure. I'd like to have a for loop to initialize the clusters to default values in stead of wiring 6 times to 6 different clusters. I've been thinking to programmably reference them by their string name, and then use an enum type to loop through their names. Is there a way to reference the cluster by name programmably?

0 Kudos
Message 1 of 5
(3,112 Views)

You can get a list of front panel objects from teh FP property and then find the controls with the names you want.

 

SInce the refs to the objects will be generic array you will have to cast the refs so look over this nugget on using control references (stop after you find what you want, the nugget gets dirty at teh end).

 

Have fun!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 5
(3,105 Views)

You can start at this by creating cluster of references or array of references. To define the cluster of references on the BD, create the ctrl reference, then create a constant from the reference to use in the cluster definition. If using array you'll get a coercsion dot due to different data type of the array elements. You can use Label.Text to get the ctrl name, or array the names, search for the name to process.

 

Below is a paste to get started.

 

ClusteByStringName.PNG

Message 3 of 5
(3,087 Views)

You could also use the Ctrl Val.Set method (VI class).  Leave the VI reference unwired so it acts on 'This VI'.  This lets you reference a control by its name (Label).

0 Kudos
Message 4 of 5
(3,077 Views)

There you have it 3 different ways to reference cluster ctrl by string name.  1, FP property, 2, ctrl property 3, invoke method. Using the FP property output an array of ctrl references (no need to for defining the cluster by name as I did). Use invoke method, you need to know the name of the ctrl for input to the set ctrl method. Smiley Wink

0 Kudos
Message 5 of 5
(3,042 Views)