LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can you programatically get at an xcontrol label from within the xcontrol?

I'm working on an XControl, and I have include a VI in the control project definition to do some of the crunching. In this VI I would like to use the Label Text assigned to this instance of the XControl. The goal is to have my XControl write some info out to file on UnInit and so if the programmer used two or more instances, I would need to tag the info with the control's lable to be able to identify which control it came from. Is it simple and I have missed it?
0 Kudos
Message 1 of 5
(2,805 Views)

Hi,

Because XControls work similarly to OOP, you cannot get a reference to itself easily (such as with a property node within a regular VI). However, you could use a reference control to the XControl itself and go from there. So I would say no, it isn't really as simple as a regular property node, but it certainly can be done. Hope this helps!

Stephanie

0 Kudos
Message 2 of 5
(2,772 Views)
Perhaps I misunderstand your question but I think this is possible.


Inside the XControl's Facade.vi, you can get a reference (Refnum) to the XControl from the Container State. You can use this reference to get the label of the XControl (Label.text property). If you put it in the right event in the facade vi (I tried the timeout case, but any of the events should work), you can store it in Display State, so you don't need to get it each time.


If you need the XControls label in a vi that uses it, you can do so just as you would with any other control. Simply right click the terminal, and select create reference, and wire a Label.text property to it.


Regards,


Wiebe.
Message 3 of 5
(2,762 Views)

Thanks Wiebe,

Yep, missed the fact that the XControl's Refnum is part of the Facade State Control. This is exactly what I needed - glad it was simple.

0 Kudos
Message 4 of 5
(2,749 Views)
Thanks Wiebe!
0 Kudos
Message 5 of 5
(2,746 Views)