Output values can be handled. If you're building an array on the For loop, also grab the iteration count into a shift register when you "stop" the loop, then you'll know where in the array it stopped.
Otherwise you fill an array with "NAN", empty string or some other known value so you can tell where it stopped. Ed