LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I only execute code in a certain tab when that tab is selected?

Solved!
Go to solution

I want the code inside one of my tabs to only run when that tab is selected. I'd like to read the value of the tab chosen to compare it to a constant (that tab), and if true, run it.  I don't know how to read the value of a tab selector though, I don't understand the structure.

0 Kudos
Message 1 of 3
(2,109 Views)
Solution
Accepted by topic author wendyloo262

You can't have "code inside a tab."  A tab control is a front panel item that that allows you to show different groups of other controls that are contained on the tab pages.

 

The tab control has a terminal on the block diagram.  If you want to determine if a certain tab is selected, you just wire that to an equals function.  Compare it to a constant.  If you right click on the terminal and pick Create Constant, you now have a constant that contains all the pages and you can select the one you want to compare to.

Message 2 of 3
(2,103 Views)
Ravens is absolutely right. Don't over-engineer your code. Sections of code should run when needed and should not depend on a mostly cosmetic feature on the front panel. Still, you can wire the tab terminal directly to a case structure. You can also listen for a "value changed" event of the tab control.
0 Kudos
Message 3 of 3
(2,098 Views)