As noted – define a variable, outside of the loop, and initialize it with a known value (even
). When desired, give this variable a value and (if appropriate) jump out of the loop with
. Now, one way or the other, the variable that you've defined "has some value." And, this value isn't anyone's leftovers: it's got the value that you gave it.