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

2018-09-06 11:17

阅读:717

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

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
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)=.aspthen
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
publicsubprintf
response.writeASP:&<br/>
response.writeTotalLinesCoded:&asplines&<br/>
response.writeTotalBytes:&aspbytes&&<br/>
response.writeTotalIndividualElements(words)Typed:&aspwords&<br/>
response.writeJScript:&<br/>
response.writeTotalLinesCoded:&jslines&<br/>
response.writeTotalBytes:&jsbytes
endsub
endclass

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

dimo
seto=newCOUNT_CODE
o.path=bluedestiny/
o.count
o.printf
%>



评论


亲,登录后才可以留言!