From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stop and go to the beginning

Hello,
 
I have two code. One receive and execute command (the user doesn't touch this one) where many loops are running in a big while loop.
 
The other write command and if I want to abort the execution I push the buttom abort.
 
How can I return to the beginning of the while loop (in the first code describe) wherever I am in my execution program ? What's the most elegant way to do this ?
 
Thanks
 
Paul
0 Kudos
Message 1 of 5
(2,205 Views)

You shouldn't use the abort button in the normal operation of a program.  It and the run continously button should only be used for the sake of debugging.

You should set up a stop button and setup all of of your inner loops to stop running when that button goes true.  Since there are multiple loops, you will need to use local variables and set the action of the button to switch as opposed to latch.  In the last operation of the outer while loop (and you will need to use wires and dataflow to make sure it executes after the inner loops stop), write a false to a local variable of the stop button to effectively reset it and it will behave like you had it set to latched all along.  All the loops will stop, the stop button resets itself, and the next iteration of the outer while loop will take over.

Of course you will still need an overall program stop button to stop the outermost loop

 

0 Kudos
Message 2 of 5
(2,187 Views)
It goes well if it's a while loop. What I do if it's an indexed for loop. Can I stop that one ?
0 Kudos
Message 3 of 5
(2,164 Views)

I don't know of any way of stopping a For loop early.

In order to do it, you may have to convert it to a While loop so that you get the stop terminal.  Then your stop conditions would be the stop button OR the iteration node +1 is >= number of elements in the array that you are indexing into the loop.

Message Edited by Ravens Fan on 07-27-2007 10:59 AM

0 Kudos
Message 4 of 5
(2,160 Views)
Calculate Number of Elements - 1 outside the loop and compare that to i inside the loop. Eliminates one addition per iteration.

Lynn
0 Kudos
Message 5 of 5
(2,151 Views)