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

Better way to declare in loops


Post New Thread Reply   
 
Thread Tools Display Modes
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 01-25-2016 , 15:54   Re: Better way to declare in loops
Reply With Quote #21

Quote:
Originally Posted by friagram View Post
it's not all pre allocated, pretty often I do
decl array [size]
where size is the call count of a dynamic array or some config variable.

you can use static too, which should allocate it on runtime and keep it there...

decl still works too, as reading out a string or variable that is not initialized gives you the appropriate garbage output.
decl is not supported in the new syntax, I use statics for arrays (including strings) and I declare other vars normally
TheDS1337 is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 01-25-2016 , 15:58   Re: Better way to declare in loops
Reply With Quote #22

you can use the old syntax.
the new syntax brings nothing to the table anyway.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 01-25-2016 , 16:15   Re: Better way to declare in loops
Reply With Quote #23

Quote:
Originally Posted by friagram View Post
you can use the old syntax.
the new syntax brings nothing to the table anyway.
^ The new syntax is nothing more than a different way of writing. Too many people think that staying with old syntax means resorting to an outdated, less functional method.
thecount is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 01-25-2016 , 17:15   Re: Better way to declare in loops
Reply With Quote #24

It's not like that, well I prefer the new syntax because it feels more like a C++, and it helps me to learn C++ too 2 in 1
TheDS1337 is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 01-25-2016 , 19:43   Re: Better way to declare in loops
Reply With Quote #25

Quote:
Originally Posted by DeagLe.Studio View Post
It's not like that, well I prefer the new syntax because it feels more like a C++, and it helps me to learn C++ too 2 in 1
I wasn't referring to you specifically, but in general. Do as you wish.

Last edited by thecount; 01-25-2016 at 19:43.
thecount is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 01-26-2016 , 00:09   Re: Better way to declare in loops
Reply With Quote #26

https://forums.alliedmods.net/showpo...84&postcount=8
Potato Uno is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 01-26-2016 , 06:06   Re: Better way to declare in loops
Reply With Quote #27

Quote:
Originally Posted by Potato Uno View Post
You can move it to the global scope if you're using it in a function that is called frequently. (Most notorious example is OnGameFrame, lesser knowns are some sdkhook callbacks.)

Then the zeroing is done on compile time (according to asherkin).
not wat I was talking about but that's silly anyway, just use decl
Miu is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 01-26-2016 , 08:37   Re: Better way to declare in loops
Reply With Quote #28

Quote:
Originally Posted by Miu View Post
not wat I was talking about but that's silly anyway, just use decl
decl is cancer that should not be touched (read post above yours).
Potato Uno is offline
SM9
Veteran Member
Join Date: Sep 2013
Location: United Kingdom
Old 01-26-2016 , 09:06   Re: Better way to declare in loops
Reply With Quote #29

PHP Code:
#define MyCleanLoop(%1) for(int %1 = 0; %1 <= 100; %1++)

MyCleanLoop(iInteger)
{
    if(
iInteger == 0) {
        continue; 
// Skip none multiples of 5.
    
}
    
    
PrintToChatAll("Integer = %d"iInteger);


Last edited by SM9; 01-26-2016 at 09:24.
SM9 is offline
h3bus
AlliedModders Donor
Join Date: Nov 2013
Old 01-26-2016 , 09:19   Re: Better way to declare in loops
Reply With Quote #30

Quote:
Originally Posted by Potato Uno View Post
decl is cancer that should not be touched (read post above yours).
Is that because scripters can make mistakes with it?

Or is there another reason, because this one isn't a good reason at all.
h3bus 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 19:21.


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