Easy way to count total lines of code?
Posted: Wed Oct 06, 2010 7:42 pm
How can I view how many lines of code my program has? For example if I am building a project that spans several include files?
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Procedure ExamineDirectoryRecursive(Path.s, Pattern.s, List _List.s())
Protected Dir = ExamineDirectory(#PB_Any, Path, Pattern)
If Dir
While NextDirectoryEntry(Dir)
AddElement(_List())
_List() = Path + DirectoryEntryName(Dir)
Wend
FinishDirectory(Dir)
EndIf
Dir = ExamineDirectory(#PB_Any, Path, "")
If Dir
While NextDirectoryEntry(Dir)
If DirectoryEntryType(Dir) = #PB_DirectoryEntry_Directory
If DirectoryEntryName(Dir) <> "." And DirectoryEntryName(Dir) <> ".." And FindString(DirectoryEntryName(Dir), "Examples", 0) = 0
ExamineDirectoryRecursive(Path + DirectoryEntryName(Dir) + "\", Pattern, _List())
EndIf
EndIf
Wend
FinishDirectory(Dir)
EndIf
EndProcedure
Dir.s = "C:\project\" ; use final \
NewList _List.s()
ExamineDirectoryRecursive(Dir, "*.pp", _List())
I = 0
ForEach _List()
;Debug _List()
ReadFile(0, _List())
N = I
While Not Eof(0)
I + 1
S.s = ReadString(0)
If Trim(s) = ""
Empty + 1
EndIf
Wend
Debug LSet(Str(I-N), 5) + _list() ;ReplaceString(_List(), Dir, "")
Next
Debug "Total lines: " + Str(I)
Debug "Non-empty lines: " + Str(I - Empty)
Debug "Empty lines: " + Str(Empty)
Curiosity mainly. And trimming redundant code. And it would just be nice to know.Fluid Byte wrote:What's the point of counting the lines? Wanna' show off?
could it possible that you use the DEMO versionNituvious wrote:Curiosity mainly. And trimming redundant code. And it would just be nice to know.Fluid Byte wrote:What's the point of counting the lines? Wanna' show off?
Yes I use the demo version but it's not because I want to avoid the restriction. I haven't ever gotten close to the restriction before. I am simply curious how many lines of code I put into a project, that's all.Rings wrote:could it possible that you use the DEMO version
and wanna avoid the Restrictions ?
Thank you!PB wrote:There's nothing illegal about reducing the number of lines anyway.
cheers ~ VeraTotal lines: 5644
Non-empty lines: 4266
Empty lines: 1378