Thanks:  0
Likes:  0
Dislikes:  0

# Thread: While ( ( OCEBwLimit != 3 ) && ( OCEBLeft < 1000 )

1. ## While ( ( OCEBwLimit != 3 ) && ( OCEBLeft < 1000 )

I'm having an ancient moment as my while statement is not working the same way I want it to. if OCEBwLimit is 3 and OCEBLeft is 234 then the while will continue? Both variables need to be true for the while to end, correct?

While ( ( OCEBwLimit != 3 ) &amp;&amp; ( OCEBLeft &lt; 1000 ) )

I would like the while to end if OCEBwLimit is 3 and OCEBLeft is greater than 1000.
Thanks,
BMD

2. ## Re: While ( ( OCEBwLimit != 3 ) && ( OCEBLeft < 1000 )

Taking your first scenario, if OCEBwLimit is 3 and OCEBLeft is 234, then you have FALSE AND TRUE which is FALSE so the while loop will exit. So, no, with those values the loop will not continue because one of the expressions evaluates as false.

If you wish it to continue on those values change &amp;&amp; to ||

3. ## Re: While ( ( OCEBwLimit != 3 ) && ( OCEBLeft < 1000 )

I thought BOTH vales needed to be true for the while to end. For future knowledge if the while is false or any value is false the while ends.

4. ## Re: While ( ( OCEBwLimit != 3 ) && ( OCEBLeft < 1000 )

Using the AND logic as you are, both expressions need to be TRUE for the While loop to continue. As soon as one is FALSE, the while loop exists.

If you want it to continue looping so long as one item is true, you need to use OR logic. That way, as soon as they BOTH go false, the loop stops.

5. ## Re: While ( ( OCEBwLimit != 3 ) && ( OCEBLeft < 1000 )

Thank You - works excellently.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.