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
<%
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\
' \ from codeproject.com
' \ Calculate code
' \ 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
' Constructor, create a new FSO instance
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
' Establish regular expressions,
' In fact, it should not be written here, it should be written in the constructor (including the variations used should be placed in the constructor),
' Because it's recursive, it's definitely less efficient to re-establish regular instances each time you call yourself. As few initialization values as possible in recursion
' I will not change, if you are interested, you need to change the friend
Set rx = new RegExp
Rx.ignorecase = True
Rx.global = True
Rx.pattern = "+"
' Recursive files for the current folder. Including JS and ASP
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
' Recursively all subfolders of the current folder.
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
%>