Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cleaning up the project and source code
Message
From
12/09/2008 16:57:44
 
 
To
11/09/2008 20:41:27
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01346920
Message ID:
01347233
Views:
19
>This is something that has been put off a long time. We have many files that are no longer used. What is the best plan of attack to get as clean of a project as we can, where the code that is in it, and in the supporting directories, is only the code we need/use? We have a table driven menu, so some things will have to be looked at manually to see if they are needed. We can create an empty project, add the main program, and rebuild, but won't that also pickup up stuff that's not used if there is any reference to it in other code? How should we proceed? I'm tired of having useless files, references, a large EXE and bad code reference searches in this application. Any help appreciated.

Create a new project, add the main project, build project. Then run a little code to see what's in the directory tree, but not in the project. Here's a version I'm showing in one of my sessions at Southwest Fox:
*==============================================================================
* Program:             CHECKFORUNUSEDCODE.PRG
* Purpose:             Make a list of unused files in a project's folders
* From:                Practical Tips for Working with Existing Code
* Copyright:           (c) 2007, Tamar E. Granor, Ph.D.
* Last revision:       02/27/07
*==============================================================================

LPARAMETERS cProject, cPath
* Look for unused code

LOCAL oProject, nCounter, oFile
LOCAL nDirs, nDir, aDirs[1]

MODIFY PROJECT (m.cProject) nowait

oProject = _VFP.ActiveProject
* First, make a list of all files in project
LOCAL aProjFiles[oProject.Files.Count]

nCounter = 0
FOR EACH oFile IN oProject.Files
	nCounter = m.nCounter + 1 
	aProjFiles[m.nCounter] = UPPER(oFile.Name)
ENDFOR 

CREATE CURSOR Unused (mFileName M)

* Now traverse directories
* First, make a list of directories
nDirs = ALINES(aDirs, m.cPath, 1, ";", ",")
CREATE CURSOR DirsToCheck (mDirName M)

FOR nDir = 1 TO m.nDirs
	INSERT INTO DirsToCheck VALUES (FULLPATH(aDirs[m.nDir]))
ENDFOR 

LOCAL aFiles[1], cOldDir, cFile, nFilesToCheck, cExt

cOldDir = SET("Default") + CURDIR()

SCAN
	IF DIRECTORY(mDirName)
		CD ALLTRIM(mDirName)
		nFilesToCheck = ADIR(aFiles, "*.*")
		FOR nFile = 1 TO m.nFilesToCheck
			cFile = aFiles[m.nFile, 1]
			cExt = JUSTEXT(m.cFile)
			IF INLIST(cExt, "PRG", "SCX", "MNX", "FRX", "VCX", "QPR")
				IF ASCAN(aProjFiles, FORCEPATH(m.cFile, ALLTRIM(mDirName)), -1, -1, 1, 7) = 0
					INSERT INTO Unused VALUES (FORCEPATH(m.cFile, DirsToCheck.mDirName))
				ENDIF
			ENDIF
		ENDFOR
	ENDIF 
ENDSCAN

CD (m.cOldDir)

* Put results into clipboard for easy management
_ClipText = ""
SELECT Unused
SCAN
	_ClipText = _ClipText + ALLTRIM(mFileName) + CHR(13) + CHR(10)
ENDSCAN 

RETURN
Tamar
Previous
Reply
Map
View

Click here to load this message in the networking platform