Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determining # of lines of code in a project
Message
De
20/03/2002 11:46:26
 
 
À
20/03/2002 11:16:41
Stephen Hunt
Admit Computer Services Inc.
Farmingdale, New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00635003
Message ID:
00635036
Vues:
16
>Is there any way to determine the total # of lines of code in a project ?
>
>Thanks for your help
>Stephen J. Hunt

Stephen,

Here's a quick way. I just changed my SeachProject routine a bit.

You have to adjust it a bit.
#define TRUE .T.
#define FALSE .F.

function ProjectCountLines()

	if( type('Application.ActiveProject') <> T_OBJECT )
		? 'no active Project'
		return FALSE
	endif
	
	
	oProject = Application.ActiveProject
	
	local i, t, n
	
	&& t = therm(oProject.Files.Count, 'Searching')
	n = 0
	
	for i = 1 to oProject.Files.Count
		obj = oProject.Files.Item(i)
		
		&& =t.Update(i, obj.Name)
		n = n + objCountLines(obj)
	endfor
	
	return n
endfunc
*--------------------------------------------------------------------------
Function	objCountLines(obj)
	local sError, s
	sError = on('Error')
	Private OpenError
	OpenError = FALSE
	
	s = select(0)
	
	local n
	n = 0
	
	do case
	case (obj.Type = FILETYPE_DATABASE)		&& Database (.DBC)
		on error OpenError = TRUE
		use (obj.Name) again in 0 shared noupdate
		on error &sError
		if( OpenError )
			? chr(7), 'Cannot open ', obj.Name
			return FALSE
		endif
		select (justfname(obj.name))
		locate for (ObjectType = 'Database') and (ObjectName = 'StoredProceduresSource')
		if( !found() )
			? chr(7), 'Cannot find ', 'StoredProceduresSource in ', obj.Name
			use in (obj.Name)
			select (s)
			return FALSE
		endif
		n = n + CountLines(obj.Name, '', 'StoredProceduresSource', Code)
		use in (obj.Name)
		select (s)
		
	case (obj.Type = FILETYPE_FREETABLE)	&& Free table (.DBF)
		
	case (obj.Type = FILETYPE_QUERY)		&& Query (.QPR)
		
	case inlist(obj.Type, FILETYPE_FORM, FILETYPE_CLASSLIB)			&& Form (.SCX), Class Library (.VCX)
		on error OpenError = TRUE
		use (obj.Name) again in 0 shared noupdate
		on error &sError
		if( OpenError )
			? chr(7), 'Cannot open ', obj.Name
			return FALSE
		endif
		select (justfname(obj.name))
		scan all for !empty(Methods)
			n = n + CountLines(obj.Name, Parent, ObjName, Methods)
		endscan
		use in (obj.Name)
		select (s)
		
	case inlist(obj.Type, FILETYPE_REPORT, FILETYPE_LABEL)		&& Report (.FRX)
		on error OpenError = TRUE
		use (obj.Name) again in 0 shared noupdate
		on error &sError
		if( OpenError )
			? chr(7), 'Cannot open ', obj.Name
			return FALSE
		endif
		select (justfname(obj.name))
		scan all
			if( !empty(Expr) )
				n = n + CountLines(obj.Name, '', '', Expr )
			endif
			if( !empty(SupExpr) )
				n = n + CountLines(obj.Name, '', '', SupExpr)
			endif
		endscan
		use in (obj.Name)
		select (s)
		
	case (obj.Type = FILETYPE_PROGRAM)		&& Program (.PRG)
		n = n + CountLines(obj.Name, '', '', FileToStr(obj.Name))
	case (obj.Type = FILETYPE_APILIB)		&& API Library (.FLL)
		&& skip
	case (obj.Type = FILETYPE_APPLICATION)	&& Application (.APP)
		&& skip
	case (obj.Type = FILETYPE_MENU)			&& Menu (.MNX)
		&& skip
	case (obj.Type = FILETYPE_TEXT)			&& Text (.TXT, .H., etc.)
		n = n + CountLines(obj.Name, '', '', FileToStr(obj.Name) )
	case (obj.Type = FILETYPE_OTHER)		&& Other file types not
		&& skip
	otherwise
		? 'CountLines: object Type not supported ', obj.Type
		return FALSE
	endcase
	
	return n
endfunc
*--------------------------------------------------------------------------
function CountLines(FileName, ParentName, ObjectName, MethodCode, txt)

	local aa[1],n
	
	n = alines(aa, MethodCode)
	
	return n
endfunc
*--------------------------------------------------------------------------
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform