07-11-2012 05:49 PM
Hi,
im trying to enable or disable certain tabs on a tab control based on a toggle switch.
when i put the whole thing in a while loop and give the control as false to the conditional terminal, then my program works fine and i can toggle the tabs on and off. However, if I include a stop button in an event structure it does not work.
It does not work even if i give a default false value coupled with a boolean OR.
The image is attached.
Any suggestions?
Solved! Go to Solution.
07-11-2012 05:52 PM - edited 07-11-2012 06:02 PM
Remember that the loop will not go to the next iteration until all of the code has completed execution. This includes the event structure. It will be sleeping waiting for an event to happen. You can add a timeout event. You then have to wire to the blue hourglass in the upper left.
But it would be better to add a value change event for the 'Boolean' control and put the code in your false case inside of that event case. Also put the terminal in there with the code. It keeps things organized and allows the latching action of booleans to work.
One more little bit of unrelated information. The index array function does not need the 0 and 1 constants wired to it. The default is 0..n. Just a tip.
07-12-2012 12:48 AM
Hi again Steve,
Thank you for your previous advice.
I am now facing another problem. In the example i had before, I was toggling between only 2 tabs, So I used a Boolean.
If I have 3 or more tabs and want to toggle among all of them, how would I use the event structure in that case?
The control is no more Boolean but instead numeric. If I try just putting a value change for that control, the program just toggles one tab enabled and stays there.
Any thoughts?
07-12-2012 09:50 AM
Just create a value changed event for the numeric. Inside of that event case wire the control to delete from array. Enable the one that was deleted and iterate over what is left and disable those. You can also write to a local variable of the tab control to select the enabled tab if you want. Make sure that you check the value of the numeric against the number of pages or you will get an invalid reference error. The function in the code below with the Boolean that goes to the case structure is In Range and Coherce.