현재 폴더에있는 JS 코드 및 ASP 코드의 줄 수를 계산하고 코드의 바이트 수를 계산할 수 있습니다.
샘플 코드가 있습니다
코드 사본은 다음과 같습니다.
<%
'////////////////////////////////////////////////////////
'//
'// codeproject.com에서
'// JS 및 ASP 코드를 계산합니다
'// BlueDestiny를 수정합니다
'//mail:BlueSeStinyAt126.com
'//
'////////////////////////////////////////////////////////
옵션 출현
응답 .buffer = false
classCount_code
Privatefso, Spath
privateasplines, jslines, aspbytes, jsbytes, aspwords
privatesubclass_initialize
setfso = createobject ( "Scripting.FilesyStemObject")
Endsub
privatesubclass_terminate
setfso = 아무것도
Endsub
PrivateFunctionErate (Path)
Dimfolder, 폴더, 파일, 파일, ts, txt, arr, f
setfolder = fso.getfolder (경로)
setfiles = 폴더.files
Dimrx, c
setrx = NewRegexp
rx.ignorecase = true
rx.global = true
rx.pattern = "+"
foreachfileinfiles
ifright (file.name, 4) = ". Asp"orright (file.name, 3) = ". js"
setts = file.openastextstream
ifts.atendOfStreamThentxt = ""ELSETXT = TS.READALL
ts.close
txt = rx.replace (txt, "")
txt = 대체 (txt, vbcrlf & vbcrlf, vbcrlf)
arr = split (대체 (txt, vbcrlf, ""), "")
aspwords = aspwords+ubund (arr)
arr = split (txt, vbcrlf)
ifright (file.name, 4) = ". ASP"그런 다음
Asplines = Asplines+Ubund (ARR)
aspbytes = aspbytes+len (txt)
또 다른
JSLINES = JSLINES+UBUND (ARR)
jsbytes = jsbytes+len (txt)
endif
endif
다음
setfolders = 폴더 .subfolders
foreachfinpolders
iteratef.path
다음
최종 기능 장애
PublicpropertyletPath (S)