LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Obtain Control Reference

Hi,

   Is anyone aware of an object in existance that I can wire a control in one end (or the local variable of a control) and get the control reference out? If not I could consider building one..?

Many thanks, Alec

0 Kudos
Message 1 of 13
(3,450 Views)

Right-click on your control.  Choose Create->Reference.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 13
(3,437 Views)

Hi Crossrulz,

   Sorry you misunderstand, I would like an OBJECT that will perform this operation, I need to programatically aquire the reference of a control. IE a sub vi who's input is a control (any, will probably be a polymorphic suite) and who's output is a reference to that control.

0 Kudos
Message 3 of 13
(3,431 Views)

Hey,

 

(I guess) it could be done with VI scripting.. but this solution is limited ... VI scripting is not available in the Runtime Engine.

 

Regards,

CMW

0 Kudos
Message 4 of 13
(3,423 Views)

There is no direct method to achieve this (as far I know), but I can suggest another way around. Instead of wiring the control to the sub vi you can wire the label of that control to that sub vi along with the main vi reference, inside you can gather the reference of all the controls of the main vi and take the reference according to the label. Will that suffice?

-----

The best solution is the one you find it by yourself
0 Kudos
Message 5 of 13
(3,416 Views)

I was also going to suggest searching by the label.  You will need to use the VI reference to get the Front Panel reference to get a reference to all of the controls and indicators on the front panel.  You can then do a search in a FOR loop for the control you want.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 13
(3,409 Views)

OK What I really want is to be able to wire a control or local variable up to a VI and have that VI return the control's label. I assumed the best way to acheive this was using the reference.

0 Kudos
Message 7 of 13
(3,401 Views)

Hi, I had thought that maybe there would be a way of using scripting to find out which control is wiring to the VI's specific clone and use that information to seach through the 'Controls[]' off the calling VI to decide which was the correct reference, would I HAVE to use scripting for this?

0 Kudos
Message 8 of 13
(3,400 Views)

You may be able to do this, but it is very indirect, will require some experimentation, and will probably never work reliably. Before starting, it is important to understand that, to scripting, a subVI and a VI are very different. A VI is the code. A subVI is the calling mechanism between a VI and its called code (also, unfortunately, called a subVI).  Try the following:

  1. In the called code, get a list of the VIs callers (VI property Callers).
  2. In each of these callers, use the Traverse for GObjects VI to find the subVIs
  3. Query each of these subVIs for what its calling VI is. At this point, you have located the subVIs of interest.
  4. At each of these subVIs, get a reference to the wire connected to the terminal of interest.
  5. Get the array of terminals connnected to this wire and find the one which is the source.
  6. Cast the terminal reference to a control terminal reference (it will fail if connected to something else).
  7. Use the control terminal reference to fetch the control reference. DONE!

I believe all of this will work in the run-time engine, since you are not changing anything, but check each property and method you use in the LabVIEW help to confirm.

 

Good luck!

 

0 Kudos
Message 9 of 13
(3,383 Views)

Hi,

   I have got a bit of the way through writing this code, I think, but at the moment when I try and cast down the reference to the subVI i get rejected, can anyone spot what im doing wrong here (I apologise for the scruffy code, this is a bit of a work in progress)
Many thanks, A;ec

0 Kudos
Message 10 of 13
(3,376 Views)