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: 

how to exit a for loop

i have a "for" loop that contains an operation that produces a true value when the output is a specific number.  i used a flat sequence to perform the operation and a constant of 10 for the "for" loop iteration.  My probem is that when i get to interation three, this produces the boolean to go to true and i want to exit the "for" loop instead of going through the rest of the iterations.  is there a way to exit the loop when this goes true.  for this particular application i need a for loop and can't use a while loop.  thank you

attached is a sample vi that gets the jist of what i am doing.
0 Kudos
Message 1 of 4
(2,468 Views)
Use a while loop instead.

Also, the sequence structure in your example is unecessary.  The dataflow will enforce the sequence of operations.

Message Edited by jasonhill on 08-23-2006 01:13 PM

Message 2 of 4
(2,466 Views)

Yes there is no break and continue inside of a for loop unlike many other languages.  This is most likley due to breaking the dataflow model.  2 choices esist

1. while loop with a counter (i>=itteration max) stop ORed with your additional stop condition (stop is true)

2.  Use a for loop but place the code inside of a case structure (less efficient since the loops will continue to spin eventhough there is no code to execute)

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 3 of 4
(2,457 Views)
thank you
0 Kudos
Message 4 of 4
(2,444 Views)