Click to See Complete Forum and Search --> : Lines of code counter?
timeshifter
Jan 22nd, 2007, 05:36 PM
I'll be honest, I have absolutely no idea where a question like this belongs...
Anyway, does anyone know of a good program to count lines of code? I would just use VB's locator, but I have a lot of white space for readability purposes, so it's not accurate... It says I'm at almost 500 lines in this program, but I know it's not that high. Any ideas?
crptcblade
Jan 22nd, 2007, 05:45 PM
Have you tried MZ Tools (http://mztools.com/index.htm)?
MartinLiss
Jan 22nd, 2007, 06:00 PM
Moved. Please don't post technical questions in the General Discussion / Chit Chat forum. Having "absolutely no idea where a question like this belongs" isn't a reason for putting it in Chit Chat. I moved it here but it could also be in a language-specific forum and if you want me to move it to one of them then PM me and I will.
Valleysboy1978
Jan 23rd, 2007, 05:42 AM
Tried Google?? (http://www.google.com/search?hl=en&q=code+line+counter&btnG=Google+Search)
penagate
Jan 23rd, 2007, 06:17 AM
I count blank lines. It impresses the fools who rely on statistics like lines of code.
;)
Dnereb
Jan 23rd, 2007, 07:21 AM
Counting Lines to evaluate the amount of labour someone does results in inefficient coding.
If IsFormCompleted() then DoSomething()
will become:
Dim Answer as Boolean
Dim ReturnValue as Variant
Answer = IsFormCompleted
Debug.Print Answer
If Answer = True then
ReturnValue = Dosomething()
Debug.Print ReturnValue
end if
MartinLiss
Jan 23rd, 2007, 09:57 AM
Ive attached an application that I wrote several years ago that counts lines of code in VB5, VB6 and C++ V5 applications. When you run it first read Help|Overview.
Shaggy Hiker
Jan 23rd, 2007, 10:57 AM
There're some good points here. I've always wondered about the meaningfullness of line counting. I never felt that what PG was suggesting was quite ethical, but if everyone agreed that a blank line shouldn't be counted, I think everyone would agree that a comment line shouldn't be counted....and then what about End If? When you write an If statement, you don't write the End If, because it is generally created for you (sometimes you end up writing it anyways). It is an essential line of code, yet it HAS to exist for every If statement that is not a single line, so does an If statement count as one line, or two?
Then you get to Dnereb's point. There are many ways to pad out lines if there is some reason to do so. If you get "graded" on the number of lines taken to do some task, many statements can be split into multiple steps. One was presented there, and though it is a bit excessive, it's a fine example of just how thoroughly you can pad something out. On the other hand, there are times when it is actually superior to pad things out. You could have a line like:
str1 = str1.Substring(CInt(Str2.substring(0,CInt(str2.substring(5,1)),str2.substring(6,str2.substring(7,1)) )
(which, aside from being a monstrosity, may be missing a parenthesis).
While such a line could conceivably be written, and perform correctly (not this one, maybe, but it might be close), it is really hard to read. Splitting all the pieces out would make any debugging vastly easier, and it would pad the line count.
MartinLiss
Jan 23rd, 2007, 11:02 AM
My app allows you to choose whether or not to count blank lines and/or comments.
oceanebelle
Jan 23rd, 2007, 08:42 PM
I made a application regarding this using VB, not yet perfect but you can specify any language and single line and multiple line comment exlusion if you want them.
basic just excludes all the blank spaces. it would be a nice headstart.
However i made it 2004 so i'm not sure if i can support hehehe.
If you want to have the source, Just pm me a reminder and i'll try to look for it at home and post it here.
oceanebelle
Jan 25th, 2007, 08:33 AM
Here it is...
did it in VB6 Enterprise Edition with Service Pack 5 or 6 I think.
Anyone is free to butcher the application as I know there are a lot of areas for improvement. a lot was done brute force and I believe there is one bug.
No support is being done for this though, ahahaha as I have basically forgotten about this, worked on it late in 2004. So forgive the n00bie code.
This is version 2 because the first version was in Delphi and I have to rewrite and redesign the code from scratch, when that delphi dll expired in license. LOLz So I made version 1 and used it for about 1 month and then killed it. So within a 2 week time frame i had to come up with another similar file reader.
oceanebelle
Jan 25th, 2007, 08:44 AM
Functionalities...
1) Disregard all white spaces.
2) Allow flexibility of file type to be analyzed.
That is, when a file is of java, then strip blanks as well as those in comments (when specified). same goes for other file types
3) Allow for several types of files to be read and analyzed.
User can go for directories, and when a file is found check it into the summary file
4) Allow for several different types of files to be analyzed.
User can check for more than one type of file and have it analyzed with each file custom filter out option in effect.
5) Allow saving of summary of files into a CSV so that users can freely format the generated summary file.
6) Allow update of existing summary files (provided the form is still in tact).
7) Management of file filters.
8) Allow users to specify which files to search only.
9) Count no. of chars, no. of lines
10) Specify line with longest length and it's line number (note minus the characters)
Hmmm I think that's about it.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.