[try Beta version]
Not logged in

 
Particular loop

Mar 20, 2009 at 6:45pm
Hello!
I know it may be an obvious question, but I haven't to manage an answer anywhere.
How do I create a loop that starts when "b" condition is satisfied, but doesn't stop if "b" condition is no longer verificated?
Thanks!
Last edited on Mar 20, 2009 at 6:46pm
Mar 20, 2009 at 7:12pm
Please define what "verificated" means. I'm not familiar with that word.
Mar 20, 2009 at 7:18pm
Do you mean something like this?
1
2
3
4
if( /* b condition is true */ )
{
    // Insert loop here
}
Mar 20, 2009 at 9:22pm
I have determinated that a while loop is in order...
1
2
3
4
while( /*insert true condition*/ )
{
    // do something
}
Mar 22, 2009 at 6:54pm
Yes, but with this code, if for example b is at start = 1, then = 2, and finally again = 1, and my while loop needs b to be = 2 to work, in the case I have written before, when b comes back to 1 the while loop stops.
Mar 22, 2009 at 7:40pm
I think what you are saying is that once condition b is satisfied, start the loop, but keep the loop running even if condition b is no longer satisfied.
Perhaps:
1
2
3
4
5
if(/*condition b*/){
     do{
          //loop stuff
     }while(true);
}

This way the loop will continue to run even after b is no longer satisfied. Is that what you're trying to do?
Topic archived. No new replies allowed.