* 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