Results 1 to 12 of 12

Thread: Lines of code counter?

  1. #1

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Lines of code counter?

    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?

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    Re: Lines of code counter?

    Have you tried MZ Tools?
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Lines of code counter?

    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.

  4. #4
    Fanatic Member Valleysboy1978's Avatar
    Join Date
    Nov 2004
    Location
    Planet Xeoroaniar CC Posts:1,928,453,459,361
    Posts
    770

    Re: Lines of code counter?

    Tried Google??
    Life is one big rock tune

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Lines of code counter?

    I count blank lines. It impresses the fools who rely on statistics like lines of code.


  6. #6
    Fanatic Member Dnereb's Avatar
    Join Date
    Aug 2005
    Location
    Netherlands
    Posts
    863

    Re: Lines of code counter?

    Counting Lines to evaluate the amount of labour someone does results in inefficient coding.
    Code:
    If IsFormCompleted() then DoSomething()
    will become:
    Code:
    Dim Answer as Boolean
    Dim ReturnValue as Variant
    
    Answer = IsFormCompleted
    Debug.Print Answer
    If Answer = True then
        ReturnValue = Dosomething()
        Debug.Print ReturnValue
    end if
    why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
    for every question you ask provide an answer on another thread.

  7. #7
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Lines of code counter?

    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.
    Attached Files Attached Files

  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Lines of code counter?

    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.
    My usual boring signature: Nothing

  9. #9

  10. #10
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Lines of code counter?

    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.
    Last edited by oceanebelle; Jan 25th, 2007 at 09:45 AM.

  11. #11
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Lines of code counter?

    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.
    Attached Files Attached Files

  12. #12
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Lines of code counter?

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width