計算當前文件夾中,有多少行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
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)
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)