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

Hello,

I have written a small VI that outputs all key values of a section of my config file to a cluster.

I would like to give the string indicators in the cluster the relating key name.

I think that I am along the right lines using a property node to try and change the controls label but when I run the VI I get the following error message....

LabVIEW:This property is writable only when the VI is in edit mode, or this method is available only when the VI is in edit mode.

 

Could someone be kind enough to tell me where I am going wrong? I may have got the complete wrong end of the stick and there is a simpler way of doing what I am trying to achieve!

 

I have attached a screen grab of my block diagram in case that sheds any light what I am doing wrong.

 

Thanks for looking,

 

Iain

 

 

0 Kudos
Message 1 of 16
(3,268 Views)

See this link.  Caveat:  I've heard that LV NXG doesn't have this feature.  On purpose(?)  (facepalm.)

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 16
(3,264 Views)

Hello Bill,

 

Thanks for getting back to me Smiley Happy

 

I have done as the example shows but get the error:

LabVIEW:  In run mode, LabVIEW cannot get or set a property for a control part that has not been created.

 

so I have tried to handle this by wiring the error line through a flat sequence structure and into my property node so the cluster is populated before I try and change it. (see attached)

 

unfortunately this didn't work for me....

0 Kudos
Message 3 of 16
(3,254 Views)

You are going wrong exactly as the error message is telling you.

You cannot change labels of controls on a VI that is running; you can only do that when the VI is in edit mode.

This of course means that a VI can never change any of its own labels.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 4 of 16
(3,251 Views)

Follow the link to find out why you get the error.

 

Usually, you loop over the cluster controls, and get the label from the controls. Then use the label as a key to the configuration file. So you actually use the labels as identifier. You'll don't have the order dependency anymore.

 

Controls[] can be put outside the for loop, and auto indexing can be used instead of the index element with "i" wired to it...

 

And one more point... Show Label property won't give an error if the label was not created jet. Setting  the label will give an error if it was not created jet. This is very tricky... If you create a new control, it will not have a label. Even the steps in the link won't fix that. You need to at least once, show the label during edit time, or during running it will not be there!

0 Kudos
Message 5 of 16
(3,250 Views)

That behavior is a holdover from the days when memory was small and expensive.  Since most controls don't use a caption, in order to save memory, by default, controls have no caption.  It's not just that the caption is an empty string, the caption object does not exist (that's what is causing your error).  If you put something (anything) in the caption while editing the VI, the editor will create the caption object (likewise, if you change the caption to an empty string, the editor will delete the caption object).  Also, in your block diagram, the "To More Specific Class" and "To More Generic Class" functions are completely superfluous.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 6 of 16
(3,233 Views)

@paul_cardinale wrote:

If you put something (anything) in the caption while editing the VI, the editor will create the caption object (likewise, if you change the caption to an empty string, the editor will delete the caption object). 


Replacing the Caption with an empty string will not delete it. Once it is created, it will be there. I don't think there is a way to delete it completely, to gain back those precious bytes.

 

I've started a thread on a private forum. This issue should at least be added to the Support article. As it is now, the instructions simply do not work (on new controls).

0 Kudos
Message 7 of 16
(3,218 Views)

Hello again,

 

thank you all for your replies!

It doesn't seem as straight forward as I had hoped...

I will look into the method of changing the names once the VI has closed and see if that is of any use to me!

 

Thanks again, I appreciate the advice.

 

Iain

0 Kudos
Message 8 of 16
(3,177 Views)

@iain.wicks wrote:

It doesn't seem as straight forward as I had hoped...


You're 95% there. It's just that labels can't be changed when the VI is running. Use Captions if you want that, and make sure the Captions are there. 

 


@iain.wicks wrote:

I will look into the method of changing the names once the VI has closed and see if that is of any use to me! 


Closed or not is not relevant. The VI should not be running if you want to edit labels! Use a static VI reference works great.

 

 

 

 

Message 9 of 16
(3,162 Views)

Hello,

sorry for the slow response I have been on annual leave!
I will have a go with using a static VI reference as you suggested and try to edit the labels that way!

Thanks

 

Iain

0 Kudos
Message 10 of 16
(3,093 Views)