LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create local variable for stop button

Hi,

i have a switch case structure and in every case one while loop. problem is that every while loop have own stop-button, so i have 3 or 4 stop buttons on my front panel... i can't create local for a true/false-button? what to do?

thanx in advance

vedran
0 Kudos
Message 1 of 4
(6,958 Views)
Hi vedran,

First, u have to make Local Variables for one stop button, and copy them to all While Loops.
Second, you have to change the mechanical action for this button to "Switch when Pressed".
Third, at the exit of each While Loops you have to pass a "FALSE" to that Stop Button.

I attached a VI that demonstrate that action...

The Bush-Man
Message 2 of 4
(6,951 Views)
Hello,

I didn't understand if you are having problems with creating the local variable or getting an error due to it.
But I'll explain what I think you must do in order to do what you want...
First right click in the button or in the terminal and choose create local variable.
Then use it in your code to stop all your loops.
Now you should have a broken arrow, meening that you cannot have local variables of buttons with latch mechanical actions.
Go to the front panel, right click on your button and choose mechanical action.
Thne choose one of the non latch, normally the first one. But from now on, you have a switch, meening that it will not go from true to false automaticaly, you press it once it goes to true and then, when you press it again, it goes from true to false.
So you have to do this yourself. at the end of the while loops, wire a false to a local variable of the button so you can use it in the next iteration.

Note that this is some strange programming, normally you should use some event structures to control your user interaction.

Hope this helps,
Paulo
0 Kudos
Message 3 of 4
(6,950 Views)
If all case structures just contain a while loop, you could probably rewrite it to have a single while loop with the case structure inside the while loop instead. Now you can get away with a single stop boolean on the while loop (but outside the case structure).

My suspicion however is that your program is overly complicated. There is always more than one possibility to solve a code issue and it is better to select a solution that avoids local variables. If you want, you can attach your code and we can probably come up with a much better alternative for the same functionality. 🙂
0 Kudos
Message 4 of 4
(6,942 Views)