统计有多少行JS代码和ASP代码
统计有多少行JS代码和ASP代码
发布时间:2016-12-29 来源:查字典编辑
摘要:计算当前文件夹中,有多少行JS代码和ASP代码,并且还可统计代码有多少字节有示例代码复制代码代码如下:

计算当前文件夹中,有多少行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)

spath=server.mappath(s)

endproperty

publicsubcount

iterate(spath)

endsub

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

o.path="bluedestiny/"

o.count

o.printf

%>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新ASP教程学习
热门ASP教程学习
编程开发子分类