Raised This Month: $ Target: $400
 0% 

Better way to declare in loops


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-25-2016 , 13:29   Re: Better way to declare in loops
Reply With Quote #1

Quote:
Originally Posted by h3bus View Post
I'm really not familiar with the new syntax. Does this mean decl has no equivalent in new syntax?
Exactly. There is no decl in new syntax.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 01-25-2016 , 15:46   Re: Better way to declare in loops
Reply With Quote #2

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.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 01-25-2016 , 15:54   Re: Better way to declare in loops
Reply With Quote #3

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 #4

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 #5

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 #6

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 #7

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 #8

https://forums.alliedmods.net/showpo...84&postcount=8
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 #9

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
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 08:51.


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