Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Dont suppose anyone's written a...

Reply
Thread Tools

Dont suppose anyone's written a...

 
 
Rob Meade
Guest
Posts: n/a
 
      11-02-2003
....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


 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      11-02-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"


 
Reply With Quote
 
 
 
 
Rob Meade
Guest
Posts: n/a
 
      11-02-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


 
Reply With Quote
 
Steven Burn
Guest
Posts: n/a
 
      11-02-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 <> wrote in message
news:s47pb.3689$...
> ...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
>
>



 
Reply With Quote
 
Aaron Bertrand [MVP]
Guest
Posts: n/a
 
      11-02-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" <> wrote in message
news:s47pb.3689$...
> ...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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Generally, are the programs written by C++ slower than written by C10% ? KaiWen C++ 102 09-14-2011 11:12 PM
don't suppose... =?Utf-8?B?cm9kY2hhcg==?= ASP .Net 4 11-22-2005 12:57 AM
OnBubbleEvent firing when it's not suppose to Dan ASP .Net 5 11-16-2004 01:29 AM
Why do you suppose this newsgroup attracts such off-the-wall posts? Tom Dacon Microsoft Certification 1 08-19-2004 12:33 AM
Re: Can a usercontrol written in C# be used in Web Forms that is written in VB.Net? Steve C. Orr, MCSD ASP .Net 1 08-24-2003 12:06 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57