Raised This Month: $12 Target: $400
 3% 

[solved] C-c-c-combo breaker


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 01-25-2011 , 03:03   [solved] C-c-c-combo breaker
Reply With Quote #1

PHP Code:
while(true)
    while(
true)
        while(
true)
            while(
true)
                while(
true)
                    break 
5
why the hell it wont to compile?
don't tell me it can't be done :<
__________________

Last edited by Leonardo; 01-25-2011 at 08:58.
Leonardo is offline
psychonic

BAFFLED
Join Date: May 2008
Old 01-25-2011 , 06:51   Re: C-c-c-combo breaker
Reply With Quote #2

Use for(;;) instead of while(true).
psychonic is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 01-25-2011 , 08:34   Re: C-c-c-combo breaker
Reply With Quote #3

no no
compiler said "an error in line ..."
where break
while(true) used for example.

EDIT:
another code
for example too
PHP Code:
new iTarget = -1;
do {
    for(new 
iClient=1iClient<=MaxClientsiClient++)
        if(
KvGetNum(hKeyValue"value")==iClient)
        {
            
iTarget iClient;
            break 
2;
        }
} while(
KvGotoNextKey(hKeyValue)); 
__________________

Last edited by Leonardo; 01-25-2011 at 08:39.
Leonardo is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 01-25-2011 , 08:46   Re: C-c-c-combo breaker
Reply With Quote #4

Quote:
break
Terminates and exits the smallest enclosing do, for or while statement from any point within the loop other than the logical end.
The break statement moves program control to the next statement
outside the loop.
Nothing about the number after it.
__________________
FaTony is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 01-25-2011 , 08:49   Re: C-c-c-combo breaker
Reply With Quote #5

am I dreamed or something?
__________________
Leonardo is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 01-25-2011 , 08:53   Re: C-c-c-combo breaker
Reply With Quote #6

break does not use any integers.
Nor does SourcePawn use any PHP manuals.
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 01-25-2011 , 08:54   Re: C-c-c-combo breaker
Reply With Quote #7

Quote:
Originally Posted by Monkeys View Post
break does not use any integers.
Nor does SourcePawn use any PHP manuals.
all dreams are broken...
__________________
Leonardo is offline
psychonic

BAFFLED
Join Date: May 2008
Old 01-25-2011 , 08:55   Re: C-c-c-combo breaker
Reply With Quote #8

Sorry, I missed the point of the first post. I believe FaTony is correct. You can't use the break keyword to break out of multiple loops.
psychonic is offline
psychonic

BAFFLED
Join Date: May 2008
Old 01-25-2011 , 09:24   Re: [solved] C-c-c-combo breaker
Reply With Quote #9

You can still do it, just in a less elegant way. Keep a bool var for each loop you want to be able to exit out of. Set it to true if you want to exit and check it at the start of each iteration, breaking if true. GOTOs would also work, but I think sp removed them.
psychonic is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 01-25-2011 , 09:26   Re: [solved] C-c-c-combo breaker
Reply With Quote #10

Or make sub-function and return.
__________________
FaTony 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 09:08.


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