LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I set boolean text property on a button programatically?

Hi
 
I'm trying to set the boolean text on a series of buttons on the front panel based on text read from a configuration file.  The problem I get is error 1073 saying that the property is only writable in edit mode.  How do I set this property as I load the VI?
 
Cheers
 
Mark.
0 Kudos
Message 1 of 17
(12,679 Views)
Hi Mark,

I have just tried it on LV 8.20 and it works fine. I was not loading the string from a file but using a control (should be the same).

VI diagram image attached.

ssk
0 Kudos
Message 2 of 17
(12,668 Views)
Mark,

I am doing this regularly on running VIs. Can you post a simple VI which demonstrates the error. If you only have the problem with config files but it works OK with a constant or control like ssk showed, then include a sample config file as well.

Lynn
0 Kudos
Message 3 of 17
(12,659 Views)

Thanks for the reply, I've just realised my problem is slightly different I was trying to change a label.  I still have a problem though.  The added complication I have is that I am finding the control by its name then I need to set the boolean text property.  I'm doing it this way so I can loop though several buttons named Button1, Button2......etc.  After finding the button I want to change I can't figure out how to access the boolen text propery.

 

See attached VI.

0 Kudos
Message 4 of 17
(12,653 Views)
The problem you have getting all the control references is that you only get generic properties.

I would create an array of references of all the boolean controls instead. Take a look at the image attached.

ssk


0 Kudos
Message 5 of 17
(12,642 Views)

Thanks ssk, that looks like it should be suitable for my application because I only have a limited number of buttons.

Cheers,

Mark.

0 Kudos
Message 6 of 17
(12,634 Views)
U try this example.
 
-Kumar B
Message 7 of 17
(12,629 Views)
You cannot change the Label at run time. The Label is the name of the control and changing it is editing the program. However you can display and make visible the Caption rather than the Label. The Caption can be changed via property nodes.

The boolean text can be changed via the Strings[4] property. This property is only available for Booleans, so you must convert the control reference to a more specific class to gain access to that property.

If you wish to have separate texts for the True and False states or if you wish to manipulate the Caption programmatically, you must select the Boolean Properties dialog from the front panel at edit time and amke the caption visible and enable multiple boolean texts. The Caption can also be made visible by context clicking on the control. I have been unable to find a way to take a default boolean control right off the palette and create and show a caption or switch to multiple strings programatically.

The True -> False and False -> True strings are used in Latch when Released or Switch when Released modes.

I modified your example to show this.

Lynn
Message 8 of 17
(12,624 Views)

Kumar and Lynn have answered this already but let add about the captions.

In previous version of LV (prior to 7 ?) you could show a caption out of the box. Since that time, the captions appear to only be created while in edit mode. Once created, they can be manipulated.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 17
(12,618 Views)
Ben,

That is interesting. Was this change to captions in the newer versions an improvement?!? Or was there some problem with the previous versions which required a fix?

Lynn
0 Kudos
Message 10 of 17
(12,610 Views)