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: 

programmatically name cluster indicators by Key name

I am having the same issue, but with renaming cluster elements programmatically.  I can change the label text of the cluster itself programmatically by running the VI dynamically and using the panel.controls[] property, but it doesn't extend to doing the same for the cluster elements.

By the way, the error message you are getting is a real one, as you can't change label names of a VI that is already running,  any properties of a VI cannot be done by the VI itself at run time.  You need to call the VI dynamically and change the properties you want to change and then save the VI before running it as shown by the example.

 
 
 

 

Download All
0 Kudos
Message 11 of 16
(772 Views)

Hi Blocka,

 


@Blocka04 wrote:

I can change the label text of the cluster itself programmatically by running the VI dynamically and using the panel.controls[] property, but it doesn't extend to doing the same for the cluster elements.


Get the reference of that cluster, then use this reference to read the "Elements[]" property of that specific cluster!

 

The cluster itself is a "child" of the frontpanel and so included in the "Frontpanel.Controls[]" reference array, but the elements within the cluster are "childs" of that cluster and not of the frontpanel. So you have to query the "Cluster.Elements[]" of that cluster to reference them…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 12 of 16
(769 Views)

@Blocka04 wrote:

You need to call the VI dynamically and change the properties you want to change and then save the VI before running it as shown by the example.

 

No, you need to open the VI dynamically, then change the labels.

 

Calling the VI is optionally.

 

Saving is also optional. Saving the VI won't be possible in executables.

 

Without changing, the changes will stay in memory as long as the VI (instance) is in memory.

 

Note that changing the labels won't mark the VI as changed! So a save all won't (always) save the label changes.

Message 13 of 16
(758 Views)

Hi GerdW,

 

Thanks very much for your reply,  I had a second thought about it and my solution is attached.

I open and run the BasicVI.vi dynamically and when it runs it populates a global with the reference to the cluster that contains the elements I want to rename, I then close the VI, use the reference global to allow me to use the Controls[] properties, index the controls in a for loop, and then rename them. 

Attached is the zip file that contains the solution.

0 Kudos
Message 14 of 16
(745 Views)

@Blocka04 wrote:

Hi GerdW,

 

Thanks very much for your reply,  I had a second thought about it and my solution is attached.

I open and run the BasicVI.vi dynamically and when it runs it populates a global with the reference to the cluster that contains the elements I want to rename, I then close the VI, use the reference global to allow me to use the Controls[] properties, index the controls in a for loop, and then rename them. 

Attached is the zip file that contains the solution.


Why not return Controls[] as an output of the VI?

 

Use Get Control Value after running, and the global becomes obsolete.

0 Kudos
Message 15 of 16
(727 Views)

If you return controls[] as an output after a statically run VI, it would still not work when you try to change the label names of the cluster elements and it comes out with an error message, "this property can only run when the VI is in writable mode".  I have tried it.

About Get Control Values after a run, I have never come across this VI and it would be vey kind of you to provide a simple example about how to use it.

0 Kudos
Message 16 of 16
(714 Views)