Click here to Skip to main content
13,860,804 members
Click here to Skip to main content
Add your own
alternative version


13 bookmarked
Posted 29 May 2007
Licenced CPOL

Visual FoxPro Lines of Code Analysis

, 5 Jan 2012
Rate this:
Please Sign up or sign in to vote.
Lines of Code Counter in C# that analyze FoxPro Projects (PJX)


Being a long-time Visual FoxPro turned .NET developer, I am now faced with the task of porting several existing applications from VFP to .NET - and providing customers with estimates of effort for each project as well.

Since I could not find a Source Lines of Code (SLOC) tool for VFP projects, I decided to build one. This article is the result of my work and I hope someone else will find this tool useful in their work.

Using the Application

The VFPLOCCounter application is very easy to use - simply select the VFP *.pjx file you wish to analyze and then click the Process button.

The application will analyze code found in Forms (*.scx), Menus (*.mnx), Class Libraries (*.vcx), Programs (*.prg), Includes (*.h), and Reports (*.frx).

For each file, the application generates the following metrics:

  • Total number of lines of source
  • Number of methods
  • Number of lines of Code
  • Number of Comment lines
  • Number of Blank lines
  • Percentage of Code lines
  • Percentage of Comment lines
  • Percentage of Blank lines

Note the Percentage calculations are all based on the total lines in the file or project, for example, the Percentage of Code lines is calculated as follows:

fileCodePercent = (fileCodeLines / fileTotalLines) * 100;

After all files in the project have been analyzed, the application generates the above metrics for the project as a whole.

When the analysis is completed, you can produce a printable report by clicking the Print Preview button which is positioned to the right of the Process button.

Points of Interest

The report that the application generates is built using Microsoft Reporting and was for me an interesting excursion into this way of building reports.



  • 29th May, 2007: Initial post
  • 31st August, 2011: Updated project to Visual Studio 2010, search "supexpr" field for code in report files
  • 30th December, 2011: Updated project, corrected bug that did not correctly account for lines containing a single character (such as a ? or a single tab). Also corrected bug that prevented Include files (.h) from being examined. Also correctly count comment lines that begin with "&&" as comment lines and not code lines. Starting a comment line with "&&" is considered bad form in VFP, but is allowed nonetheless.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Mark Miller
Software Developer (Senior)
United States United States
I develop software for a leading healthcare system in Northern Illinois.

You may also be interested in...


Comments and Discussions

QuestionVery helpful Pin
Member 121784781-Dec-15 2:24
memberMember 121784781-Dec-15 2:24 
Member 1085328727-Feb-15 6:46
memberMember 1085328727-Feb-15 6:46 
QuestionJust what I needed Pin
stoked20-Nov-14 13:08
memberstoked20-Nov-14 13:08 
QuestionDatabase Stored Procedure not analysed Pin
Member 818889431-Aug-11 11:23
memberMember 818889431-Aug-11 11:23 
QuestionIt's not working for all files Pin
Member 818891631-Aug-11 7:32
memberMember 818891631-Aug-11 7:32 
AnswerRe: It's not working for all files Pin
Mark Miller31-Aug-11 8:03
memberMark Miller31-Aug-11 8:03 
GeneralRe: It's not working for all files Pin
Member 818891631-Aug-11 11:17
memberMember 818891631-Aug-11 11:17 
GeneralRe: It's not working for all files Pin
Member 818889431-Aug-11 11:30
memberMember 818889431-Aug-11 11:30 
GeneralRe: It's not working for all files Pin
Mark Miller31-Aug-11 18:56
memberMark Miller31-Aug-11 18:56 
GeneralJIT Depuration Pin
santimaza9-Jun-11 2:17
membersantimaza9-Jun-11 2:17 
GeneralRe: JIT Depuration Pin
Mark Miller9-Jun-11 8:03
memberMark Miller9-Jun-11 8:03 
Generalvfp lines of code counter Pin
Mike Poirier18-Dec-09 4:50
memberMike Poirier18-Dec-09 4:50 
GeneralRe: vfp lines of code counter Pin
Mark Miller21-Dec-09 10:28
memberMark Miller21-Dec-09 10:28 
Generalfoxpro project books Pin
microcomputershisar2-Dec-08 21:22
membermicrocomputershisar2-Dec-08 21:22 
GeneralRe: foxpro project books Pin
Mark Miller3-Dec-08 5:51
memberMark Miller3-Dec-08 5:51 
QuestionDoes it work for Memo fields? Pin
Andrey Chekh30-Oct-07 11:51
memberAndrey Chekh30-Oct-07 11:51 
GeneralVery Well Done Pin
IgDev5-Jun-07 8:43
memberIgDev5-Jun-07 8:43 
GeneralRe: Very Well Done Pin
Mark Miller5-Jun-07 10:24
memberMark Miller5-Jun-07 10:24 
GeneralCorrections Pin
Alexke4-Jun-07 23:24
memberAlexke4-Jun-07 23:24 
GeneralRe: Corrections Pin
Mark Miller5-Jun-07 5:41
memberMark Miller5-Jun-07 5:41 
GeneralMigration Lines of Code Counter Pin
rajantawate1(http//www.tawateventures.com29-May-07 9:52
memberrajantawate1(http//www.tawateventures.com29-May-07 9:52 
GeneralRe: Migration Lines of Code Counter Pin
Mark Miller29-May-07 10:11
memberMark Miller29-May-07 10:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.190214.1 | Last Updated 5 Jan 2012
Article Copyright 2007 by Mark Miller
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid