LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to control the iteration count of FOR loop in LV 8.6

Hi All,

 

I want to control the iteration count of FOR loop, is it possible? I've a FOR loop, which iterates 5 times. I'm checking a condition in FOR loop and if I get FALSE then I want to repeat the same i.e in this case iteration count (i) of FOR loop should not get incremented. Thus this FOR loop will iterate 6 time instead of 5 times.

 

Thanks & Regards,

Shrini

0 Kudos
Message 1 of 3
(2,934 Views)

You can't repeat an iteration of a For loop.  Then it would no longer be a For Loop.  A For loop iterates a fixed number of times.  (Though in newer versions of LabVIEW, there is a Conditional For Loop where you can terminate the Loop early).

 

What you need to do is use a While Loop and maintain your iteration "counter" in a shift register.  If you want the next number, add a 1 to it.  If you want to repeat the number, then you don't and just feed the same number into the shift register.

0 Kudos
Message 2 of 3
(2,925 Views)

 


I want to control the iteration count of FOR loop, is it possible?

 

Conrol Iteration.JPG


 I'm checking a condition in FOR loop and if I get FALSE then I want to repeat the same

 


CHeck Condition.JPG

i.e in this case iteration count (i) of FOR loop should not get incremented.

Here you needs to write a logic to generate your own (i) Value. In the for loop you cant programatically change the no of iteration after it gets into the loop. better go with the wile loop.

 

 

While loop.JPG

 

Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
Message 3 of 3
(2,921 Views)