Raised This Month: $32 Target: $400
 8% 

Skip some number using While


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
anon12
Member
Join Date: Aug 2013
Old 07-21-2014 , 02:44   Skip some number using While
Reply With Quote #1

How can I skip a certain number using Whileloop?

Example:
It will loop a number from 1 -500 however I don't want 200-300 to be counted.
anon12 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-21-2014 , 03:14   Re: Skip some number using While
Reply With Quote #2

Code:
for ( new i = 1 ; i <= 500 ; i++ ) {     if ( i == 200 )         i = 301; }
__________________

Last edited by Black Rose; 07-21-2014 at 04:10.
Black Rose is offline
anon12
Member
Join Date: Aug 2013
Old 07-21-2014 , 04:20   Re: Skip some number using While
Reply With Quote #3

Thanks,

I have this, but it still creates a number from 1 to 649. Why is that? :/
PHP Code:
new i=0;
    while( 
i<=649/12)
    {
        if( (
12*i)+== 388)
        {
            
493
        
}
        if( (
12*i)+>= 649)
            break;
            
        
menu_additemmenui+1"\\w%L (Image from:%d to: %d)"id,"TXT_MENU", (12*i)+1min((12*i)+12,649));
        
i++;


Last edited by anon12; 07-21-2014 at 04:22.
anon12 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-21-2014 , 05:07   Re: Skip some number using While
Reply With Quote #4

Your code doesn't even compile . . .

You need to look at the definition of the menu_additem() function.
Why are you doing a whole bunch of multiplying? It is entirely unnecessary.

Explain EXACTLY what you are trying to do.

P.S. (12*i)+1 is ALWAYS an odd number and will therefore never be equal to 388. However, this is a moot point because you are are doing this very wrong.
__________________
fysiks is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 07-21-2014 , 05:09   Re: Skip some number using While
Reply With Quote #5

12*i+1 can't be 388. Your code is very confusing
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
Bladell
Senior Member
Join Date: Jun 2012
Old 07-21-2014 , 09:46   Re: Skip some number using While
Reply With Quote #6

Code:
new i = 0

while(i <= 500)
{
	i++
	
	if(i >= 200 && i <= 300)
		continue
		
	//some code
}
or

Code:
new i = 0

while(i <= 500)
{
	i++
	
	if(i >= 200 && i <= 300)
		i = 301
		
	//some code
}
Bladell is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-21-2014 , 10:56   Re: Skip some number using While
Reply With Quote #7

The second one generates less loops.
My example is still better.
I suggest using a for loop for all incremental type of loops.
While loops are generally used in combination with functions that work with a more true/false statement ( != 0 or == 0 ), for example feof().
__________________
Black Rose is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:13.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode