Proper indenting
Ok, how do I "properly indent" my code? Apparently that is half of the reason my last plugin got trashed, I was using Avalanche's online auto-indenter too..
|
Well, when you "indent", you're essentially spacing a line of text, and making a visual reference to the depth of the code block. This makes it easier to read (not only for you, but for others too).
Commonly you would use 4 spaces (or 2 or 6 or 8, whatever you like best) or even the tab key when you indent a line of text, but which ever you choose, stick with it, every where u indent use the same amount of spaces (double the spaces if the depth doubles, etc..).. You would always indent any "Block" of code that is contained within the Curly-Brackets { and } A "Block" of code is essentially any code that would be surrounded by { and }, like a function contains its own block of code. This rule applies anywhere you *would* use curly-brackets (even if you dont use them due to single-statements). An example would better describe it: Code:
Notice the line spacing is "indented" within each set of curly brackets... Now, some people have a different coding style, thats okay, whichever works for you, but be Consistent!! Some people may do it like this: Code:
That's cool too...But notice each line within the surrounding code-block is indented consistently.. Also, one other thing to note, is when the curly-brackets are omitted, which is perfectly legal for blocks containing only a single code statement.. As in: Code:
deep example: Code:
Remember, any block containing more than a single statement requires curly-brackets... I hope that helps a bit.. |
My auto-indenter doesn't work with all coding styles, mainly just mine and one other.
|
Oh, I pretty much get it now..
So all I gotta do is be consistent with what I'm indenting.. For example: Code:
|
Ermm, more like this:
Code:
Try to keep the curly-brackets at the same depth as the block itself when using a curly-bracket on its own line.. |
Oh, okay... I think I've figured it out now :). Thanks.
|
:/ is this clean code or do i have to work on it a little?
Code:
(sample from my high ping kicker) |
Well, what I do is stick it in the compiler to test for loose-indentations :).
|
Quote:
Quote:
But to shorten that one long if statement (if you want) you could include <amxmisc> and use the stock access() function: Code:
|
ah, thank you... ill keep that in mind
|
| All times are GMT -4. The time now is 14:07. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.