LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating an array of main menu front panel control refs for passing to subroutines

I was looking at the controls[] property of a panel and wanted to use it to create an array of control refs that I could easily pass to subVIs from the main menu.  A problem exists in that my main menu uses a tab control with nested tab controls on one of its pages which complicates things in this arena.  My program is an event structure based main program that calls subVIs for each event activation, usually a changevalue event from a button. 

 

How do you use the controls property in this case to create a functioning program with the event handler?  The controls property of the main panel only gives you those in the panel and not in the containers such as the tab controls.

 

What is the commonly used approach here? 

0 Kudos
Message 1 of 23
(4,144 Views)

Here is a vi that does part of the job.  It gets all controls' names, and all controls of each page of a tab control.  You need to go one step further to get the controls on the tab within a tab.  To do nested tabs, you would have to check the control type, and if it is a tab control, get its items.  This may be a job for a recursive function.  The vi is written in LV2009.  At least its a start to show how to get controls on a tab.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 23
(4,133 Views)

thanks tbob

 

I have this part done already and am trying to figure out how to do a nested recursion on this exact thing and how to organize the list so that I can later easily recall the refs to controls from within subVIs.

0 Kudos
Message 3 of 23
(4,120 Views)

I think I can offer two ideas that will help you figure out how yo u want to adress this challenge.

 

1) Bundle the refs you want explicitly as shown in this image.

 

1_Bundle_Refs.PNG

 

After bundling I check to enusre all of the refs are valid (not shown, cluster to array Is ref num). 

 

Yes you have to wire them all yourslef but there a tricks to make that easier.

 

Benefit: If you move a control from one tab to another, the above does not need to be changed.

 

In this Nugget I talk about using ccontrol refs and finding refs within refs. THe included sample code...

 

 

Will demonstarte usinga single cluster what you may have to go through to get at the refs on the FP. I would be suprised if you used that code "as-is" but it does demontrate the challenge.

 

Have fun,

 

Ben

 

 

 

 

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

AAAIIIIEEEEE!!!  My lazy butt is aching after seeing Ben's code.  However, it is organized by tab controls while my method would only give a complete list with no organization as to which control belongs to which tab.  Id, I wouldn't want to have to make this choice. Smiley Tongue

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 23
(4,072 Views)

tbob wrote:

AAAIIIIEEEEE!!!  My lazy butt is aching after seeing Ben's code.  However, it is organized by tab controls while my method would only give a complete list with no organization as to which control belongs to which tab.  Id, I wouldn't want to have to make this choice. Smiley Tongue

 


 

 

 

Sorry tbob but I can only reply by teasing with the re-use code one of my co-workers wrote.

 

After getting fed-up with the above two options, he wrote an XControl that once dropped on any FP will create and maintain an Action Engine that has refs to all FP object on all FPs. The enum is populated with a "VIName_ControlName" format to easily choose any FP object from anywhere in the app. So all he has to do is drop the AE,pop-up to create the enum and then choose the ref he wants.

 

No not allowed to post that code. So you could always duplicate his stuff and never have to wire a ref down again.

 

Ben

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

If it were me, I would use this gem hidden in vi.lib (with the usual caveats, subject to change by NI, make personal copies, etc).

 

TraverseFP.png

 

HelpFPTraverse.PNG

Message 7 of 23
(4,049 Views)

Now why won't NI publicize all of these hidden special VIs?  They could be of great use to a lot of programmers.  How many other very useful functions lie hidden in vi.lib?  How about a weekly nugget to feature a new hidden vi.lib function?

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 23
(4,044 Views)
Thats exactly what I was looking for.  I cant seem to find it in my C;\prog files\NI\vi.lib directory though. 
0 Kudos
Message 9 of 23
(4,032 Views)

 


id wrote:
Thats exactly what I was looking for.  I cant seem to find it in my C;\prog files\NI\vi.lib directory though. 

 

 

 

On my system it is here:

 

C:\Program Files\National Instruments\LabVIEW 2009\vi.lib\Utility\traverseref.llb\TRef Get All FP References.vi

0 Kudos
Message 10 of 23
(4,029 Views)