統(tǒng)計有多少行JS代碼和ASP代碼
計算當前文件夾中,有多少行js代碼和asp代碼,并且還可統(tǒng)計代碼有多少字節(jié)
有示例代碼
<%
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\
'\\ 來自 codeproject.com
'\\ 計算js和asp代碼
'\\ 修改 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:" & "
"
response.write "total lines coded: " & asplines & "
"
response.write "total bytes: " & aspbytes & "" & "
"
response.write "total individual elements (words) typed: " & aspwords & "
"
response.write "jscript:" & "
"
response.write "total lines coded: " & jslines & "
"
response.write "total bytes: " & jsbytes
end sub
end class
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\示例代碼
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
dim o
set o=new count_code
o.path="bluedestiny/"
o.count
o.printf
%>
有示例代碼
代碼如下:
<%
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\
'\\ 來自 codeproject.com
'\\ 計算js和asp代碼
'\\ 修改 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:" & "
"
response.write "total lines coded: " & asplines & "
"
response.write "total bytes: " & aspbytes & "" & "
"
response.write "total individual elements (words) typed: " & aspwords & "
"
response.write "jscript:" & "
"
response.write "total lines coded: " & jslines & "
"
response.write "total bytes: " & jsbytes
end sub
end class
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\示例代碼
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
dim o
set o=new count_code
o.path="bluedestiny/"
o.count
o.printf
%>
相關(guān)文章
- ASP怎么談到應用到類的?
- 檢測函數(shù) asp class
- 遭遇ASP類的事件設計
- ASP高亮類
- Object對象的一些的隱藏函數(shù)介紹
- 淺談ASP中的類
- 在VBScript中使用類
- ASP 類專題
- 代碼與頁面的分離
- ASP代碼的對象化
- 一個asp快速字符串連接類
- 一個簡單的asp數(shù)據(jù)庫操作類
- ASP類編寫詳細說明
- 實現(xiàn)支持邏輯搜索/單詞搜索/詞組搜索+支持OR/AND關(guān)鍵字的VBS CLASS!
- ASP類Class入門 推薦
- 創(chuàng)建一個ASP通用分頁類
- 如何編寫一個ASP類
- 一個ACCESS數(shù)據(jù)庫訪問的類第1/3頁
- 分頁類,異常類
- ASP 類 Class入門