You may use Exit For to get out of a For loop early, please see the
"Exit (keyword)" topic in the E-Basic online help and take it from there.
On a style note, for some reason even young E-Prime programmers seem
to latch on to the quaint and long deprecated While...Wend statement
instead of using the much more serviceable and preferred Do...Loop
construct (please see, e.g.,
http://msdn.microsoft.com/en-us/library/661sy9w2(VS.85).aspx ). I
would ask everyone to abandon While...Wend in favor of Do...Loop;
While...Wend went out with the Commodore 64!
Finally, as in PST's NoRepeat.es example, you use a non-deterministic
algorithm instead of a deterministic algorithm. I have discussed
this elsewhere. But a deterministic algorithm, though arguably more
efficient, takes some intricate programming, and your sample size is
so small that I do not think it worth the effort. So I would have
you continue with what you are doing.
-- David McFarlane, Professional Faultfinder