04-08-2018 09:54 PM
Hello, I have a while loop that never stops so a sensor is continuously reading values. Inside of it, I have a condition that has to be met by the values given by the sensor. When it is met, it goes under a for loop that does a series of operations that end up outputting a string. The condition is only met 4 times, and I would like to save the 4 different strings created into an Array. However, I cannot seem to find a way to count how many times the condition is met and therefore goes through the for loop and make that the index of the array where the string is supposed to be saved or to keep expanding the array every time a string is outputted
Any ideas?
04-08-2018 10:32 PM
You say "when the condition is met, it goes under a For Loop". But that For Loop runs every time, and it runs for 9 iterations.
What "condition" are you talking about?
04-09-2018 06:11 AM
Sounds like you need to learn about shift registers.
04-09-2018 09:24 AM
In general, you can get the count from the count terminal of a for loop.
04-11-2018 10:36 AM - edited 04-11-2018 10:39 AM
@paul_cardinale wrote:
In general, you can get the count from the count terminal of a for loop.
NO the count terminal tells you how many times a "standard" For Loop will run before it exits.
The Iteration terminal actually counts how many times the loop has run.
In the event of a For Loop with a conditional terminal, the loop may NOT actually run the full count wired to the count terminal or the count that comes from auto indexing an array.
04-11-2018 11:05 AM
The title is "Counting how many times a for loop is executed", but the question in the post is "count how many times a condition has been met":
or: