LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use a Reference to get Other References

Hi - 

 

I just wrote a piece of code that grabs a reference to any object within a tab control. This will be quite useful for us so that we only have to pass one reference down to SubVIs instead of many, many references.

 

However, I have never really used references and property nodes in this way, so I want to get feedback on my code from people who have experience or insight with this so I can avoid any potential pitfalls later. 

 

I attached the SubVI that does this with a top level VI to try it out. Open Tab Control References.vi and then in the Control Name control type in the control name you want. Then, set the value for that data type and it will update the value to that object on Tab1 of the tab control. Note it is coded to only work on Tab1, as is.

 

I think the code works, but I am mainly looking for advice on pitfalls I might encounter later or reasons why it may not work reliably.

 

Thanks in advance! 

0 Kudos
Message 1 of 6
(2,413 Views)

zenthoef,

 

I took a look and saw a few things to fix, namely that the path and slider controls were not accounted for and threw errors.  This is easily fixed by adding cases to the case structure governing the data types.

 

You may look into creating an enum or listbox to allow the user to choose an existing control, or at least put in some error checking to prevent choosing a control that does not exist.

 

Good Luck!

 

Drew T.
Camber Ridge, LLC.
Message 2 of 6
(2,380 Views)

Thanks for taking the time to look at my code!

 

I should have been clearer because the "Tab Control References.vi" was just an example so it doesn't matter if not all the data types are accounted for. I was simply trying to get the idea accross. I am more interested in knowing if there are problems with "Get Reference in Tab Control.vi".

 

As for the enum or listbox to select existing controls: I think that is a great idea and will research that more!

0 Kudos
Message 3 of 6
(2,358 Views)

This nugget is based on the same topic but tries to approach the challenge in a generic manner. It may give you some ideas.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 6
(2,352 Views)

I have no looked at your code. You could use the Open VI Reference, Panel property, Controls[] property, search for the name of your Tab1. Using Tabs referece get the controls.

 

GetTab1.PNG

0 Kudos
Message 5 of 6
(2,323 Views)

That's more or less what my code is. Was mainly wondering if there are any pitfalls to look out for in doing that. Smiley Happy

0 Kudos
Message 6 of 6
(2,312 Views)