...little function for count lines of code?

I was going to do this a little while ago, hoping to count each line in each
file in each folder etc etc, and then determine whether it was say ASP, HTML
or comments....and give totals...

Anyone got anything like this they dont mind sharing?

Just curious...

Regards

Rob

Re: Dont suppose anyone's written a... by Bob

Bob
Sun Nov 02 07:53:47 CST 2003

Rob Meade wrote:
> ...little function for count lines of code?
>
> I was going to do this a little while ago, hoping to count each line
> in each file in each folder etc etc, and then determine whether it
> was say ASP, HTML or comments....and give totals...
>
> Anyone got anything like this they dont mind sharing?
>
> Just curious...
>
> Regards
>
> Rob

I haven't, but I can't foresee it taking more than five minutes using
FileSystemObject. Here are some resources:
http://www.aspfaq.com/filesystem.asp

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



Re: Dont suppose anyone's written a... by Rob

Rob
Sun Nov 02 09:57:25 CST 2003

"Bob Barrows" wrote...

> I haven't, but I can't foresee it taking more than five minutes using
> FileSystemObject. Here are some resources:

Hi Bob,

Thanks for the reply, I didn't think it would take long to do - but was
trying to be a bit lazy :)

If I get around to writing something I'll pop the code up here, incase
anyone else is interested (possibly not - hehe)

Rob



Re: Dont suppose anyone's written a... by Steven

Steven
Sun Nov 02 10:22:29 CST 2003

Not sure if will work in ASP but for the line count, you could try something
along the line's of;

Dim FSO
Dim strFile
Dim strFiles
Dim strLine
Dim intCount

Set FSO = CreateObject("Scripting.FileSystemObject")
Set strFiles = FSO.GetFolder(Server.MapPath(./")).Files

For Each strFile in strFiles

Open StrFile For Input As #1
Do While Not EOF(1)
Line Input #, strLine
intCount = intCount +1
Loop
Close #1
response.Write strFile & " - " & intCount
Next

Set FSO = Nothing
Set strFile = Nothing
Set strFiles = Nothing
Set strLine = Nothing
set intCount = Nothing

--
Regards

Steven Burn
Ur I.T. Mate Group CEO
www.it-mate.co.uk

Disclaimer:
My advice is provided on an 'as-is' basis. Just because I tell you
something, does not mean I am right.


Rob Meade <robb.meade@NO-SPAM.kingswoodweb.net> wrote in message
news:s47pb.3689$R96.25986231@news-text.cableinet.net...
> ...little function for count lines of code?
>
> I was going to do this a little while ago, hoping to count each line in
each
> file in each folder etc etc, and then determine whether it was say ASP,
HTML
> or comments....and give totals...
>
> Anyone got anything like this they dont mind sharing?
>
> Just curious...
>
> Regards
>
> Rob
>
>



Re: Dont suppose anyone's written a... by Aaron

Aaron
Sun Nov 02 12:48:14 CST 2003

This measures carriage returns and comments, not necessarily explicit lines
of code. You could loop through the split array to toss out empty lines or
comments, if you wanted to make it more sophisticated.

<%
folder = "<local folder path>" ' or server.mappath("/something/")
set fso = createobject("Scripting.FileSystemObject")
set fold = fso.getFolder(folder)
for each file in fold.files
if right(lcase(file.name), 4) = ".asp" then
set fs = fso.opentextfile(folder & file.name, 1)
lines = ubound(split(fs.readall(), vbCrLf)) + 1
response.write file.name & " : " & lines & " lines.<br>"
totalLines = totalLines + lines
fileCount = fileCount + 1
fs.close: set fs = nothing
end if
next
response.write "<p>Number of ASP files: " & fileCount
response.write "<p>Total lines in all ASP files: " & totalLines
set fold = nothing: set fso = nothing
%>

--
Aaron Bertrand, SQL Server MVP
http://www.aspfaq.com/

Please reply in the newsgroups, but if you absolutely
must reply via e-mail, please take out the TRASH.


"Rob Meade" <robb.meade@NO-SPAM.kingswoodweb.net> wrote in message
news:s47pb.3689$R96.25986231@news-text.cableinet.net...
> ...little function for count lines of code?
>
> I was going to do this a little while ago, hoping to count each line in
each
> file in each folder etc etc, and then determine whether it was say ASP,
HTML
> or comments....and give totals...
>
> Anyone got anything like this they dont mind sharing?
>
> Just curious...
>
> Regards
>
> Rob
>
>