Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Counting Codelines within Project
Message
De
08/02/2006 09:47:10
 
 
À
08/02/2006 07:58:38
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:
01094631
Vues:
11
Here is one I threw together quickly for a similar mgmt request. It excludes white space
 *************************************************************************
*!*	Method:			ProjMetrics
*!*	Purpose:		Calc some simple project metrics
*!*	Author:			bxk 11.11.03
*!*	Parameters:
*!*	Returns:
*!*	Modifications:	
***************************************************************************
LPARAMETERS tcProjectName

ASSERT !EMPTY(tcProjectName) .AND. VARTYPE(tcProjectName) = 'C' ;
	MESSAGE 'A project name is required'
	
ASSERT EMPTY(JUSTEXT(tcProjectName)) .OR. UPPER(JUSTEXT(tcProjectName)) = 'PJX' ;
	MESSAGE 'A _PROJECT_ name is required'
	
CLOS ALL
CLOS DATA ALL
SET CENTURY ON

LOCAL lnClassCount, lnFormCount, lnLibCount, lnLineCount, lnRptCount, ;
	lnDBFCount, lnProgCount, lcOut, lnLines, lcProjName, lcFileName, lnViewCount, ;
	lnTableCount
	
STORE 0 TO lnClassCount, lnFormCount, lnLibCount, lnLineCount, ;
	lnRptCount, lnDBFCount, lnProgCount, lnViewCount, lnTableCount
	
STORE "" TO lcOut

#DEFINE CRLF CHR(13) + CHR(10)

IF ! ('.' $ tcProjectName) 
	lcProjName = tcProjectName + '.PJX'
ELSE
	lcProjName = tcProjectName
ENDIF

USE (lcProjName) in 0 ALIAS metProject
SELECT metProject
SCAN FOR !DELETED()
	lcType = ALLTRIM(metProject.type)
	
	&& Handle project objects implemented as tables
	IF lcType $ 'M,V,K,R,d'
		lcObj = ALLTRIM(metProject.name)
		USE IN SELECT ('metObject')
		USE (lcObj) IN 0 AGAIN ALIAS metObject
		SELECT metObject
		
		DO CASE	
			CASE lcType = 'M'						&& Menus
				SCAN FOR !EMPTY(metObject.procedure)
					lnLines = ALINES(laLines, metObject.procedure)
					lnLineCount = lnLineCount + GetLineCount(@laLines)
				ENDSCAN
				
			CASE lcType = 'V'						&& ClassLibs
				COUNT TO lnCount FOR !EMPTY(class)
				lnClassCount = lnClassCount + lnCount
				lnLibCount = lnLibCount + 1
				
				SCAN FOR !EMPTY(methods)
					lnLines = ALINES(laLines, metObject.methods)
					lnLineCount = lnLineCount + GetLineCount(@laLines)
				ENDSCAN
			
			CASE lcType = 'K'						&& Forms
				lnFormCount = lnFormCount + 1
				SCAN FOR !EMPTY(metObject.methods)
					lnLines = ALINES(laLines, metObject.methods)
					lnLineCount = lnLineCount + GetLineCount(@laLines)
				ENDSCAN
			
			CASE lcType = 'R'						&& Reports
				lnRptCount = lnRptCount + 1
				SCAN FOR !EMPTY(metObject.expr)
					lnLines = ALINES(laLines, metObject.expr)
					lnLineCount = lnLineCount + GetLineCount(@laLines)
				ENDSCAN
				
			CASE lcType = 'd' .AND. metProject.key = 'CLAIMS'					&& DBC only Claims.dbc
				SCAN FOR !DELETED()
					DO CASE
						CASE objecttype = 'View'
							lnViewCount = lnViewCount + 1
						
						CASE objecttype = 'Table'
							lnTableCount = lnTableCount + 1
						
					ENDCASE
				ENDSCAN
			
		ENDCASE
		
	ELSE
		IF lcType = 'D'								&& Tables
			lnDBFCount = lnDBFCount + 1
		ELSE
			IF lcType = 'P'							&& Programs
				lnProgCount = lnProgCount + 1
				lcProg = ALLTRIM(metProject.name)
				lcLines = FILETOSTR(lcProg)
				lnLines = ALINES(laLines, lcLines)
				lnLineCount = lnLineCount + GetLineCount(@laLines)
			ENDIF
		ENDIF
		
	ENDIF

ENDSCAN

lcOut = lcOut + CRLF + CRLF 
lcOut = lcOut + DTOC(DATE())
lcOut = lcOut + CRLF + CRLF 
lcOut = lcOut + + 'Project metrics for: ' + lcProjName + CRLF + CRLF
lcOut = lcOut + 'Class Count      = ' + TRAN(lnClassCount) + CRLF
lcOut = lcOut + 'Lib Count        = ' + TRAN(lnLibCount) + CRLF
lcOut = lcOut + 'Form Count       = ' + TRAN(lnFormCount) + CRLF
lcOut = lcOut + 'Line Count       = ' + TRAN(lnLineCount) + CRLF
lcOut = lcOut + 'Report Count     = ' + TRAN(lnRptCount) + CRLF
lcOut = lcOut + 'Lookup Count     = ' + TRAN(lnDBFCount) + CRLF
lcOut = lcOut + 'Program Count    = ' + TRAN(lnProgCount) + CRLF
lcOut = lcOut + 'Data Table Count = ' + TRAN(lnTableCount) + CRLF
lcOut = lcOut + 'Data View Count  = ' + TRAN(lnViewCount) + CRLF

lcFileName = JUSTSTEM(lcProjName) + 'Metrics.txt'
StrToFile(lcOut, lcFileName)

MESSAGEBOX(lcFileName + ' Created')

CLOS DATA ALL


RETURN

***************************************************************************
*!*	Method:			GetLineCount
*!*	Purpose:		Returns lines of code in a Method, Prg.  Ignore comments
*!*					white space.
*!*	Author:			bxk
*!*	Parameters:
*!*	Returns:
*!*	Modifications:	
***************************************************************************
FUNCTION GetLineCount
LPARAMETERS taLines

LOCAL lnCount, lnLines
STORE 0 TO lnCount, lnLines

lnLines = ALEN(taLines)
FOR li = 1 TO lnLines
	IF EMPTY(taLines[li]) .OR. LEFT(ALLTRIM(taLines[li]), 1) $ '&*'
	
	ELSE
		lnCount = lnCount + 1
		
	ENDIF
ENDFOR

RETURN lnCount
>Jos,
>
>Thanks a lot. With this and an estimated guess of blank/comment-lines I can make someone very happy...
>
>B.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform