How many lines of JS code and ASP code are counted

Source: Internet
Author: User
Tags count printf split
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&AMP;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
%>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.