LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Clean way to pass references to all controls on a front panel, including nested controls?

I have a settings module for a program (using DQMH, but not sure if that's truly relevant) which has a tab control on the front panel and across the tabs, there are 21 individual front panel controls, some of which are themselves clusters of multiple controls. When I load the config file, the "load config file" state in the QMH will load all values in a subvi, write them all to the QMH state data, and set the values on the front panel. This results in a huge messy block diagram in the QMH state. I would like to put the setting the front panel values into a subvi, but I couldn't find a good way to access all controls. This is what I've got, it uses three loops and in the end gives an array that can be used to search for the individual controls by name, which I'm going to have to do 21 times. 

Please let me know if there's a better way to do this. 

Get all controls on fp.png

It works, but this has to be something with an elegant solution. In implementation, the static vi ref is replaced with a vi reference passed in.

Thanks

0 Kudos
Message 1 of 9
(615 Views)

menu -> Functions -> Programming -> Application Control -> VI Scripting -> Traverse for GObjects.vi

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 2 of 9
(596 Views)

What version of LabView has this? I'm on 2021 and there's no VI scripting palette in application control. 

0 Kudos
Message 3 of 9
(584 Views)

If I understand you correctly, you are making a settings module for an app that can read/write to INI file, etc.  If so, you might want to check out this forum post.  Maybe there are some ideas you can piggyback off of to get yours working. 

 

https://forums.ni.com/t5/Reference-Design-Content/LabVIEW-Options-Dialog-Framework-ODF/ta-p/3526554

 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 9
(579 Views)

Hey, this looks neat. I'll bookmark it. But the settings module I've made already works, I'm specifically asking about assigning values to a large number of front panel controls from a subvi so I can clean up my block diagrams. 

0 Kudos
Message 5 of 9
(573 Views)

did you enable scripting in labview ide?

0 Kudos
Message 6 of 9
(572 Views)

@Nokaroa wrote:

What version of LabView has this? I'm on 2021 and there's no VI scripting palette in application control. 


Enable scripting from the LabVIEW options:

https://www.ni.com/docs/en-US/bundle/labview/page/enabling-vi-scripting.html#:~:text=Complete%20the%....

 

0 Kudos
Message 7 of 9
(567 Views)

If you don't want to enable scripting (for instance, to keep the listed properties on a property/invoke node smaller) you can just find the VI itself:

 

\LabVIEW 20xx\vi.lib\Utility\traverseref.llb\Traverse for GObjects.vi

 

In theory this VI should work OK in a compiled EXE if you only search the front panel.  If you try to traverse a block diagram it will likely fail.

 

Also, don't forget that there is no guarantee of the uniqueness of the Label.Text field on a VI.  You might want to pair your data saving with the UID of the control and use the text field as a label of convenience rather than assignment.

0 Kudos
Message 8 of 9
(548 Views)

@Nokaroa wrote:

Hey, this looks neat. I'll bookmark it. But the settings module I've made already works, I'm specifically asking about assigning values to a large number of front panel controls from a subvi so I can clean up my block diagrams. 


My response wasn't suggesting that you replace your settings app with the one from the link.  There may be some methods of transferring references in that library that may be useful to solve your problem. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 9 of 9
(463 Views)