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

while loop


Post New Thread Reply   
 
Thread Tools Display Modes
BAILOPAN
Join Date: Jan 2004
Old 03-20-2004 , 03:40  
Reply With Quote #11

it loops through all the code between the { and }, 51 times. each time the variable i is incremented by one
__________________
egg
BAILOPAN is offline
Peli
Veteran Member
Join Date: Mar 2004
Location: San Diego, CA
Old 03-20-2004 , 03:50  
Reply With Quote #12

Oh okay I get it now thanks Bail. I wouldn't have understood what you said five minutes ago. I just read up on the "while" thing in a manual , I guess I'm learning more
Peli is offline
Send a message via MSN to Peli
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 03-20-2004 , 03:57  
Reply With Quote #13

Quote:
Originally Posted by Peli
Oh okay I get it now thanks Bail. I wouldn't have understood what you said five minutes ago. I just read up on the "while" thing in a manual , I guess I'm learning more
learning the basics is useful, because most programming languages use the same constructions (some have different syntax)...
__________________
hello, i am pm
PM is offline
devicenull
Veteran Member
Join Date: Mar 2004
Location: CT
Old 03-20-2004 , 07:01  
Reply With Quote #14

Quote:
Originally Posted by PM
Code:
new i; for (i = 0; i <= 50; ++i) {    // stuff }
Something a bit smaller
Code:
for (new i = 0; i <= 50; ++i) {    // stuff }
Just a minor thing you can do
__________________
Various bits of semi-useful code in a bunch of languages: http://code.devicenull.org/
devicenull is offline
IceMouse[WrG]
Senior Member
Join Date: Mar 2004
Old 03-20-2004 , 09:41  
Reply With Quote #15

I could have sworn that a lot of people reccomended not to make the variable in the initialization part of the loop a while back... Maybe my mind is playing tricks on me
IceMouse[WrG] is offline
Send a message via AIM to IceMouse[WrG] Send a message via MSN to IceMouse[WrG] Send a message via Yahoo to IceMouse[WrG]
MagicShot
Senior Member
Join Date: Mar 2004
Location: MN
Old 03-20-2004 , 23:55   lol
Reply With Quote #16

Will this work?
Code:
                new bool:first_time[32]     new d = 0     while (d++ <= 31) {         if (equal(first_time[d], "")) {             client_print(id, print_console, "First_Time=^"%s^"", first_time[d])             first_time[d] = false         }     }
__________________
|v|agic$hot
.
Without a Sound
MagicShot is offline
Send a message via MSN to MagicShot Send a message via Yahoo to MagicShot
IceMouse[WrG]
Senior Member
Join Date: Mar 2004
Old 03-21-2004 , 01:03  
Reply With Quote #17

No... The loop would work but the "equal(...)" function is for strings...
You would use something like:
Code:
new bool:first_time[32]     new d = 0     while (d++ <= 31) {         if (first_time[d] == 0){             client_print(id, print_console, "First_Time=^"%i^"", first_time[d])             first_time[d] = false         }     }
IceMouse[WrG] is offline
Send a message via AIM to IceMouse[WrG] Send a message via MSN to IceMouse[WrG] Send a message via Yahoo to IceMouse[WrG]
MagicShot
Senior Member
Join Date: Mar 2004
Location: MN
Old 03-21-2004 , 01:31  
Reply With Quote #18

Quote:
Originally Posted by IceMouse[WrG
]No... The loop would work but the "equal(...)" function is for strings...
You would use something like:
Code:
new bool:first_time[32]     new d = 0     while (d++ <= 31) {         if (first_time[d] == 0){             client_print(id, print_console, "First_Time=^"%i^"", first_time[d])             first_time[d] = false         }     }
Cool I think I got it figured out..
__________________
|v|agic$hot
.
Without a Sound
MagicShot is offline
Send a message via MSN to MagicShot Send a message via Yahoo to MagicShot
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 03-21-2004 , 04:16  
Reply With Quote #19

defining a variable in the initializer part of the for loop: i have seen that a (don't remember which) sc compiler version generates bad code sometimes... for example, when you use break; then, it forgets to pop the variable sometimes, so you get stack corruptions, which will result in unexpected errors.. I don't know which versions do this / which not, but i would generally not recommend it...
__________________
hello, i am pm
PM is offline
Reply


Thread Tools
Display Modes

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:34.


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