Showing results for 
Search instead for 
Did you mean: 

Check for every ? run through a while loop

I have a while loop. I'd like to know when the while loop has incremented 2 times, 3 times, 4 times, etc. For example, if I set the control to 7, I want a boolean to go positive on each 7th occurance of the loop. Any help?

(I've found several questions about using the while loop iteration, but not my specific question. Sorry if this is a repeat from somewhere).

0 Kudos
Message 1 of 5
Good Afternoon,
One way would be to connect your loop iteration to the quotient & remainder function's top input, the number of loops control to the bottom and then a check for =0 to the remainder output.

Attached is an example

Putnam Monroe
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5

LabVIEW Champion

0 Kudos
Message 2 of 5
use the quotien & remainder function .wire the iteration terminal to the X input , on the Y input wire the number of loop iterations you want to be notified about. the x-y*floor(x/y) output will be zero anytime y divides evenly into x , wire that output to the Equal to Zero function then to your boolean indicator...

0 Kudos
Message 3 of 5
Doing that is a simple modulo operation on the iteration count. Use from Numeric the "quotient & Remainder" function. Wire the iteration terminal to x and your count to y. Check the Reminder output with "Equal to 0?". This will be true for each y iteration. The first iteration will be included.

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 4 of 5
Thanks for the quick responses! For some reason I was using a shift register, an increment, checking for trailing zeros.... I forgot about the quotient & Remainder trick. Easy!

0 Kudos
Message 5 of 5