js| Statistics
Calculates how many lines of JS code and ASP code are in the current folder, and how many bytes the code has to count
There are sample code
[Copy this Code] CODE:
<%
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\
' \ from codeproject.com
' \ \ Compute JS and ASP code
' \ \ Modify Bluedestiny
' \ Mail:bluedestiny at 126.com
'\\
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Option Explicit
Response.buffer=false
Class Count_code
Private Fso,spath
Private Asplines, Jslines, Aspbytes, Jsbytes, aspwords
Private Sub Class_Initialize
Set fso = CreateObject ("Scripting.FileSystemObject")
End Sub
Private Sub Class_Terminate
Set fso=nothing
End Sub
Private function iterate (path)
Dim folder, folders, files, file, ts, txt, arr, f
Set folder = Fso.getfolder (path)
Set files = Folder.files
Dim Rx, C
Set rx = new RegExp
Rx.ignorecase = True
Rx.global = True
Rx.pattern = "+"
For each file in files
If Right (file.name,4) = ". asp" or right (file.name,3) = ". js" Then
Set ts = File.openastextstream
If Ts.atendofstream then txt = "" Else txt = ts.readall
Ts.close
txt = rx.replace (txt, "")
TXT = replace (TXT,VBCRLF&VBCRLF,VBCRLF)
arr = Split (replace (TXT,VBCRLF, ""), "")
Aspwords = aspwords + UBound (arr)
arr = Split (TXT,VBCRLF)
If Right (file.name,4) = ". asp" Then
Asplines = Asplines + UBound (arr)
Aspbytes = aspbytes + len (TXT)
Else
Jslines = Jslines + UBound (arr)
Jsbytes = jsbytes + len (TXT)
End If
End If
Next
Set folders = Folder.subfolders
For each F in folders
Iterate F.path
Next
End Function
Public Property Let path (s)
Spath=server.mappath (s)
End Property
Public Sub Count
Iterate (spath)
End Sub
Public Sub printf
Response.Write "ASP:" & "<br/>"
Response.Write "Total Lines coded:" & asplines & "<br/>"
Response.Write "Total Bytes:" & Aspbytes & "" & "<br/>"
Response.Write "Total individual Elements (words) Typed:" & aspwords & "<br/>"
Response.Write "JScript:" & "<br/>"
Response.Write "Total Lines coded:" & jslines & "<br/>"
Response.Write "Total Bytes:" & Jsbytes
End Sub
End Class
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
' \ Sample Code
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Dim o
Set O=new Count_code
O.path= "bluedestiny/"
O.count
o.printf
%>