Source Line of Code Counter
Source Line of Code Counter
.NET Framework
Since I couldn't find a SLOC (source line of code) counter that satisfies me, I decided to write one. This SLOC counter equipped with a file system browser which is very handy for precisely defining inclusion and exclusion of files/directories. Besides that, the SLOC counter supports pattern matching for file inclusion and exclusion, and directory inclusion using regular expression. The usage section of this post has a detailed list on how to use pattern match.
This LOC counter is written in Visual C# 2005. That means you need Microsoft .NET Framework 2.0 to run this program. You can download a free copy of .NET Framework from here.
Features
- File/Directory browser for selecting multiple project location
- Regular expression pattern match
- Counting results can be sorted by file name or line count
- Export counting results to file
- Custom counting rules can be defined
Basic Usage
Select a project directory and press the Start button to start counting.
You can select a counting rule to refine the counting result, e.g., to strip out comments for designated languages.
Advanced Usage
In SLOC counter, one can define patterns through regular expression to filter unwanted files. To define multiple patterns, use comma to separate each pattern. Below are examples on how to use patterns.
If you are new to regular express, this site has some excellent tutorials to get you started.
Include only files with extension .php, .html or .css:

Exclude subversion directory:

Include files which file names contain "config" and not under directories which names contain ".svn":

Custom Counting Rules
Counting rule define how lines in a file are counted. Each counting rule is defined by a regular expression. In the event that the line in the file which is being counted is matched, this line will be excluded from counting. Typical scenario for using counting rule is to exclude comments.
There are two types of counting rules: line and page, stored in <name>.line.conf and <name>.page.conf respectively, where <name> is the name of the counting rule.
In line counting rule, each line represents a counting rule in the form of regular expression. If the line in the source file matches any of the rules defined in <name>.line.conf, the this source code line will be ignored from counting.
Page counting rules are defined in a similar way except they are paired. In
Here's counting rules for PHP language are defined:
In php.line.conf:
^ *<\?php *$ ^ *\/\/.* ^ *$ ^ *\?> *$
php.page.conf
^ *\/\* \*\/ *$
Rules in php.line.conf tells the program to ignores PHP tags <php and ?>, and single line comment //.
Rules in php.page.conf tells the program to ignores multiline comment which denoted by /* */.
Creating Your Own Counting Rule
Create a counting rule in addition to bundled ones is easy. All you need to do is create these two files under the directory where you launch your application:
<name>.line.conf
<name>.page.conf
where


Sry, I am not following you. Can you show me a detailed example of what you need?
I have downloaded the YUI toolkit. I am trying to select multiple files and upload them all at once.
I would greatly appreciate any help from you, if you could send me a detailed example of how its implemented. I am trying to implement like flicker.
Cheers,
Sarika
I would gr8ly appreciate any help from you.
Cheers,
Sarika
http://www.regular-expressions.info/charclass.html#shorthand
That's a very useful tool, but I noticed a few messages like the one below:
"Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"
I don't know why does it happen. But even with that little problem I could do my job. Thanks.