[Gambas-user] R: Unending cycle "For...Next" with variable As Byte
RICHARD WALKER
richard.j.walker at ...247...
Mon Oct 1 21:36:05 CEST 2012
Problem with that is that the second "Print ii" statement is executed,
even if the loop is skipped (because of initial conditions). The
SuperBASIC version would print nothing if the initial loop conditions
indicate it should be skipped
The Gambas equivalent would be more like
For ii = 0 to 254
Print ii
Next
If (some test by which we can tell the loop has iterated at least once) Then
Print ii
End If
Also, an EXIT statement in the loop would leave the SuperBASIC FOR
loop, skipping the loop epilogue (the bit between the NEXT and the END
FOR).
A better trivial example of the loop epilogue in action might be:
FOR character = 1 to LEN$(test$)
IF test$(character) == "@" THEN EXIT character
NEXT character
REMark Character not found
character = 0
END FOR character
IF character THEN
PRINT test$(1 TO character-1) & test$(character+1 TO )
ELSE
PRINT "Not found"
END IF
More information about the User
mailing list