Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Counting Codelines within Project
Message
De
08/02/2006 06:46:45
 
 
À
08/02/2006 06:34:42
Berend Botje
Getronics Pinkroccade
Amsterdam, Pays-Bas
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de projet
Versions des environnements
Visual FoxPro:
VFP 6 SP3
OS:
Windows 2000 SP4
Divers
Thread ID:
01094573
Message ID:
01094575
Vues:
18
>Does anyone know about a tool (or a clever method/procedure) to count lines of code in a Fox-project?
>Thnx in advance...

This is from Hilmar Zonneveld:
* Create statistics (line count) for project
* By Hilmar Zonneveld

* Because of the commands used - especially project properties - this program
* requires VFP 6 or later.

* Execution can take a long time for a large project.

* Disclaimer: I consider any intent to count the number of lines in a project as prone to
* differences in opinion, inaccuracies, or even manipulation.
* For instance:
*   Should comments and blank lines be included in the line-count, or not?
*     A well-placed comment can be as important as a line of "real" code!
*   What to do about development that is basically not stored in a text-file -
*     like a form or report where you work mainly with properties,
*     in the property sheet?
*   An inefficient project, with lots of duplicate code, where inheritance or function
*     calls should have been used, will give an impressive line-count.

clear all
if type("Application.ActiveProject") # "O"
	MessageBox("Please open the project you want to analyze.")
	return
endif
create Table TmpLines (FileName C(30), Type C(1), LineCount I, Contents M)
do (_browser)
local lcTextFile, lnLineCount, lcFileContents, lnFileCount
lnFileCount = 0
FOR EACH oFile IN Application.ActiveProject.Files
	if oFile.Type $ "PKBVMRB"
		lnFileCount = lnFileCount + 1
		wait window nowait "Processing File #" + trans(lnFileCount) + chr(13) + chr(10);
			+ oFile.Name
		do case
		case oFile.Type = "P"
			lcTextFile = oFile.Name
		case oFile.Type $ "KBV"
			_oBrowser.AddFile(oFile.Name)
			_oBrowser.ExportClass(.F., "temp.txt")
			lcTextFile = "temp.txt"
			_oBrowser.RemoveClass()
		case oFile.Type $ "MRB"
			* Because of the method used, line count is terribly inflated
			* for menus, reports and labels (see output in memo field)
			do (_sccText) with oFile.Name, oFile.Type, "temp.txt", .T.
			lcTextFile = "temp.txt"
		endcase
		lcFileContents = FileToStr(lcTextFile)
		lnLineCount = occurs(chr(13), lcFileContents)
		insert into TmpLines (FileName, Type, LineCount, Contents);
			values (justfname(oFile.Name), oFile.Type, lnLineCount, lcFileContents)
	endif
ENDFOR

*!*	Codes for file-types:
*!*	d	Database
*!*	D	Free Table
*!*	Q	Query
*!*	K	Form
*!*	R	Report
*!*	B	Label
*!*	V	Visual Class Library
*!*	P	Program
*!*	L	FLL
*!*	Z	APP
*!*	M	Menu
*!*	T	Text
*!*	x	Other
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform