| LOCC Lines of Code Counter |
Locc
Counts lines of code.
Syntax
locc [drive:][path][filename] [/s] [/f:<log|xml>] [/?]
Parameters
/s
Displays files in specified directory and all subdirectories.
/v
Verbose mode (display details how each line is counted).
/f<log|xml>
Output format.
log - Table log format (default).
xml - XML formatted.
/?
Displays help at the command prompt.
Examples
The following command displays the number of lines for file hello.cs. Locc displays the number of code, command and blank lines and the total number of lines.
locc hello.h hello.cpp
Output:
14
3 3 s:\hello.h
23 7
5 s:\hello.cpp
37 + 10 +
8 = 55
Code Comment Blank Total
2 File(s)
798 bytes
Counting multiple files by using wildcards.
locc hello.h hello.c*
Counting multiple directories by including subfolders.
locc *.h *.c* /s
Counting multiple directories by using a list file. See remarks for sample list file.
locc @files.lst
Remarks
(1) You can use a list file to specify multiple files or directories to count. A list file contains a file or directory specifier per line. List file arguments are prefixed with @. You can use wildcards within list files. You can use the /s switch in combination with list files, but not within list files.
Sample list file: files.lst
hello.h
hello.cpp
include\*.h
include\*.c*
(2) You can log count totals in a log file by specifying the log command # within the list file. The log command has the following syntax:
#Filename::ProjectName
Sample list file: fileslog.lst
#countlog.txt::Hello World C# Sample
hello.cs
Sample log file: countlog.txt
2003-11-11T22:05:45: Hello World C# Sample
609 (Cd) 34 (Cm) 151 (Em)
794 (To)
2003-11-12T22:05:57: Hello World C# Sample 654
(Cd) 39 (Cm) 170 (Em)
854 (To)
(3) You can use the /v switch to display how each line is counted. Each output line is prefixed with its type. Cd..Code, Cm..Comment, Em..Empty.
Cd: #include "stdio.h"
Em:
Cd: void main()
Cd: {
Cm: // send hello message
Cd: printf("Hello world!\n");
Cd: }
(4) You can use the /f switch to set the output format. log for Table log format, which is the default format. xml for XML output. LOCC includes a xsl-stylesheet to display as HTML report.
locc helloworld.cs /f:xml >report.xml
Sample log file: report.xml
<?xml version="1.0" encoding="IBM437"?>
<?xml-stylesheet type='text/xml' href='locc.xsl'?>
<LineCount>
<CodeStatistics Filename="helloworld.cs">
<Code>9</Code>
<Comments>0</Comments>
<Empty>1</Empty>
<Total>10</Total>
</CodeStatistics>
<CodeStatisticsTotal>
<Code>9</Code>
<Comments>0</Comments>
<Empty>1</Empty>
<Total>10</Total>
</CodeStatisticsTotal>
<FileStatistics>
<Files>1</Files>
<Bytes>141</Bytes>
</FileStatistics>
</LineCount>
Using the xsl-stylesheet locc.xsl the report can be display as HTML.

Requirements
Microsoft .NET Framework 1.1
Contact
email: reinhard.wolfinger@web.de
Last modified: Mittwoch, 10. März 2004