End a for loop early in ebasic?
Adam Osth
adamosth at gmail.com
Fri Sep 11 18:13:03 UTC 2009
Hello all,
I have a program in e-basic that takes two arrays and combines them, then
randomizes and recombines them. Since I can't reuse any combinations that
were in place previously, I have a loop structure in place to detect whether
the combinations have been used. It goes something like this.
HeadColor(7) As String
HeadShape(7) As String
(takes values for each)
For a = 0 to a = 7
Heads(a) = HeadColor(a) + HeadShape(a)
/*randomize and check for repeats
Nomatch As Boolean
Nomatch = false
Matches As Integer
While Nomatch = false
Randomize HeadColor
Randomize HeadShape
* For b = 0 to b = 7
If HeadColor(b) + HeadShape(b) = Heads(b)
Matches = Matches + 1*
End If
Next b
If Matches = 0
Nomatch = true
Wend
Now -- in the highlighted FOR loop, if the If statement is true, it is
basically saying that the entire While loop needs to be repeated and
re-randomized (a match is present). Thus, the rest of the For loop is
irrelevant. Is there a statement that can be used to end the for loop, like
a break or end statement?
Also, if my code is horribly inefficient, feel free to critique me as I'm
not a trained programmer.
Any help would be appreciated! Thanks!
Adam
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en
-~----------~----~----~----~------~----~------~--~---
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.linguistlist.org/pipermail/eprime/attachments/20090911/0462adee/attachment.htm>
More information about the Eprime
mailing list