LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reseting a counter in a while loop

I have a while loop in my program and I'm using the iteration feature to tell me how many times I got through the loop. Problem is each time I call the loop, the counter is where it was the last time I called the loop. Is there any way to reset the counter to 0 on each loop call?
Intern NSWCCD Carderock.
0 Kudos
Message 1 of 3
(3,798 Views)
The i terminal is reset every time the loop starts (not a new iteration, but after its stop condition was met and it started running again).
What do you mean by "call" in "each time I call the loop"?
Can you post an example?

___________________
Try to take over the world!
0 Kudos
Message 2 of 3
(3,786 Views)
If the loop is in another loop, allowing you to "call it", you could add a shift register that is initialized by the value from the last call, and then just increment the SR (add the "i" to it). This would imply the outer loop has a SR as well to hold the last "call's" value. It would be initialized with a zero. If the loop is in a subvi then this would be a good use of the "LabVIEW2 style global" or as it is also known, the "functional global". These (the lv2 global, etc.) have been described in many places on the NI site.


Putnam Monroe
Putnam
Certified LabVIEW Developer

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


LabVIEW Champion



0 Kudos
Message 3 of 3
(3,780 Views)