|
Prediger <prediger@freemail.hu> wrote in message <249999763.136201.1265715977098.JavaMail.root@gallium.mathforum.org>...
> Dear All,
>
> I have a for cycle (such as: for j=31:-1:1) and I have a condition within the loop. If the condition is true I'd like to jump in the loop and leave out some part of the cycle. For example j runs from 31-20 than the condition becomes true therefore j runs from 15 towards the end or jumps back to 24.
> I can't figure out how to modify the value of j within the cycle.
You cannot change the loop counter inside the
loop, or the limits on the for.
So use a while loop instead, where YOU increment
the loop counter.
Or, use an if statement inside the loop, only
processing those iterations where the loop counter
is known to be appropriate.
Or you can use the if to break out of the loop if
you are known to be done, or, use a continue
to skip to the next iteration.
HTH,
John
|