LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVIs can not reference Parent Controls

Solved!
Go to solution

Is there anyway that a subVI can reference the controls on a parent VI's Front panel? Without this ability it is hard to reduce the complexity of a VI by using subVIs when a front panel control is involved. Variable Property Nodes do not appear to have the ability to reference a control in a parent VI. Is there any way to solve this?

0 Kudos
Message 1 of 10
(4,909 Views)
Solution
Accepted by topic author dbaechtel

There are two ways to do this:

 

1. Use the connector pane to give the control reference to the subVI.

 

2. Open a VI reference to the parent VI or get the reference through the connector pane. Use the Property node VI:Controls[] to get the references to all controls. You must use a loop to get the right control by checking the label. AFAIK the sequence is in tabbing order so you can use an index.

Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
Message 2 of 10
(4,903 Views)

Can you so me a sample of #2?

 

 

0 Kudos
Message 3 of 10
(4,897 Views)

This evening (GMT+2), which LV version?

Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 4 of 10
(4,886 Views)

You can use the OpenG function 'Current VIs Parents Ref' which returns the VI that calls this VI to create the following code:

22252i7C2F97B82D5EB27F

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 5 of 10
(4,866 Views)

Ton provided the code you need.

 

Instead of the OpenG function you can use Open VI Reference from the Application control palette.

Be aware that you must use the full qualified VI name if the VI is part of a LV library, e. g. MyLibrary:MyVI.vi.

Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 6 of 10
(4,850 Views)

or rather than use the OPEN VI Reference, you can set a static property node in the parent VI and pass that VI reference easy and done...

But if the parent VI is already in memory, you need only the VI name (string input) rather than a fully qualified path (path input)

 

Advantage to the first method I proposed, it works if the VI is not saved, a clone, etc.


Paul
0 Kudos
Message 7 of 10
(4,839 Views)

Generally speaking I tend to "push" the reference down into the sub-VI rather than make it "reach up" to get it. By pushing it dwon I can redirect the functionality at a new control without mods to the sub-VI. By "reaching up" the sub-VI has to be modified to look for other widgets or even if the customer points out a typo in the control name.

 

just my 2 cents worth,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 10
(4,836 Views)

@Ben wrote:

Generally speaking I tend to "push" the reference down into the sub-VI rather than make it "reach up" to get it. By pushing it dwon I can redirect the functionality at a new control without mods to the sub-VI. By "reaching up" the sub-VI has to be modified to look for other widgets or even if the customer points out a typo in the control name.

 

just my 2 cents worth,

 

Ben


I agree with Ben.  Here is an example of how I usually do this.  The main vi passes a reference to the subvi, who then sets the value of the reference.

Save both to same folder.  When opening Main, it will look for Subvi.  Just point to it.

 

- tbob

Inventor of the WORM Global
Download All
Message 9 of 10
(4,820 Views)

I will try your suggestion.

0 Kudos
Message 10 of 10
(4,794 Views)