Calculate how many lines of JS code and ASP code are in the current folder, and can also count how many bytes the code is
There is sample code
The code copy is as follows:
<%
'///////////////////////////////////////////////////////////
'//
'//From codeproject.com
'// Calculate js and asp code
'//Modify 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+ubund(arr)
arr=split(txt,vbcrlf)
ifright(file.name,4)=".asp"then
asplines=asplines+ubund(arr)
aspbytes=aspbytes+len(txt)
else
jslines=jslines+ubund(arr)
jsbytes=jsbytes+len(txt)
endif
endif
next
setfolders=folder.subfolders
foreachfinfolders
iteratef.path
next
endfunction
publicpropertyletpath(s)