LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exit a for loop

I need to use a for loop in my VI; but I need a way to exit the for loop when I hit the stop button. I found that you can add a conditional terminal to a for loop in Labview 8.5; but is there a way to do this in Labview 8.0? 
Message 1 of 11
(5,164 Views)
No. You cannot exit a for-loop in LV prior to 8.5. Smiley Sad
- Partha ( CLD until Oct 2027 🙂 )
Message 2 of 11
(5,158 Views)
So...can anything be done to get around this?  The entire for loop takes approx. 1 minute to set the voltage on a certain device, measure some input, and then collect data from other sources (using a DAQ to do the collecting). I need to find a method to hit a "stop" button and have the program go back to  a state where it sets all the ouput voltages back to zero.  However, if I hit just hit a terminate button, the program quits where it is at and the voltages that are being sent out of the DAQ do not go back to zero.  Any suggestions?
0 Kudos
Message 3 of 11
(5,145 Views)

Hi JoshRMPS,

why don´t you use a while loop?

Mike

0 Kudos
Message 4 of 11
(5,143 Views)
I wish I could...but I need to take advantage of the iteration terminal that a for loop offers to run my structures.
0 Kudos
Message 5 of 11
(5,140 Views)

Hi JoshRMPS,

can you show your vi? I think there is a solution with a while loop. Smiley Happy

Mike

0 Kudos
Message 6 of 11
(5,133 Views)
I have attached an image file of my VI.  Note that there are quite a few structures involved in the program and I am trying to find a method to get out of the for loop at any point.  Thanks.
0 Kudos
Message 7 of 11
(5,131 Views)

Hi JoshRMPS,

see the attached picutre, if i understand you right, then this should also work for you.

Mike

0 Kudos
Message 8 of 11
(5,127 Views)
I think this might work.  I will have to give this a shot and see how it works.  Thanks so much.  I will let you know how it works...but I might not get be able to get back to you until tomorrow.  Thanks.

Josh
0 Kudos
Message 9 of 11
(5,116 Views)
Looking at your VI, I think exiting the loop is the least of your problems. This VI needs to be redesigned from the ground up as one simple state machine in a single loop that fits on one screen size. Now all you need to do is switch to a special case if need arises. Instead of exiting a FOR loop prematurely, the problem is reduced to switching to a different state in a state machine.
 
With the current design, you are really painting yourself into a corner. You first need to fix the very fundamental design flaws of your code.
 
Currently, your VI is a loose collection of isolated statements, many without any defined execution order. What makes you think that the stuff outside on the left will execute before the sequences on the right? How do you guarantee that the various "smart buffers" get emptied before the first value gets entered into them? What's up with the big case structure? Are you running this in "continuous run" mode??? All your "smart buffers" could be replaced with plain shift registers!
 
 
0 Kudos
Message 10 of 11
(5,081 Views)