手机
当前位置:查字典教程网 >编程开发 >ASP教程 >统计有多少行JS代码和ASP代码
统计有多少行JS代码和ASP代码
摘要:计算当前文件夹中,有多少行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

%>

【统计有多少行JS代码和ASP代码】相关文章:

防止网站内容被小偷采集的ASP代码

asp 全面安全数据连接代码

PR值查询代码制作

ASP辅助代码

ASP动态生成的javascript表单验证代码

asp ubb代码转换成html代码

asp下同一空间多绑多哥域名的方法

硬盘文件搜索代码(ASP类)

虚拟主机重启代码

一小偷类!!有兴趣的可以看看

精品推荐
分类导航