统计有多少行JS代码和ASP代码

2014 年 8 月 10 日5930

计算当前文件夹中,有多少行JS代码和ASP代码,并且还可统计代码有多少字节
有示例代码
复制代码 代码如下:
<%
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\
'\\来自codeproject.com
'\\计算js和asp代码
'\\修改bluedestiny
'\\mail:bluedestinyat126.com
'\\
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

optionexplicit
response.buffer=false

classCOUNT_CODE
privatefso,spath
privateasplines,jslines,aspbytes,jsbytes,aspwords
privatesubclass_initialize
setfso=createobject("scripting.filesystemobject")
endsub
privatesubclass_terminate
setfso=nothing
endsub
privatefunctioniterate(path)
dimfolder,folders,files,file,ts,txt,arr,f http://www.zjjv.com/ 电脑网
setfolder=fso.getfolder(path)
setfiles=folder.files
dimrx,c
setrx=newregexp
rx.ignorecase=true
rx.global=true
rx.pattern="+"
foreachfileinfiles
ifright(file.name,4)=".asp"orright(file.name,3)=".js"then
setts=file.openastextstream
ifts.atendofstreamthentxt=""elsetxt=ts.readall
ts.close
txt=rx.replace(txt,"")
txt=replace(txt,vbcrlf&vbcrlf,vbcrlf)
arr=split(replace(txt,vbcrlf,""),"")
aspwords=aspwords+ubound(arr) http://www.zjjv.com/
arr=split(txt,vbcrlf)
ifright(file.name,4)=".asp"then
asplines=asplines+ubound(arr)
aspbytes=aspbytes+len(txt)
else
jslines=jslines+ubound(arr)
jsbytes=jsbytes+len(txt)
endif
endif
next
setfolders=folder.subfolders
foreachfinfolders
iteratef.path
next
endfunction

publicpropertyletpath(s)
spath=server.mappath(s)
endproperty
publicsubcount
iterate(spath)
endsub http://www.zjjv.com/
publicsubprintf
response.write"ASP:"&"<br/>"
response.write"TotalLinesCoded:"&asplines&"<br/>"
response.write"TotalBytes:"&aspbytes&""&"<br/>"
response.write"TotalIndividualElements(words)Typed:"&aspwords&"<br/>"
response.write"JScript:"&"<br/>"
response.write"TotalLinesCoded:"&jslines&"<br/>"
response.write"TotalBytes:"&jsbytes
endsub
endclass

'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\示例代码
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

dimo
seto=newCOUNT_CODE zjjkw.cn 电脑网
o.path="bluedestiny/"
o.count
o.printf
%>


0 0