คำนวณจำนวนบรรทัดของรหัส JS และรหัส ASP ในโฟลเดอร์ปัจจุบันและยังสามารถนับจำนวนรหัสไบต์
มีรหัสตัวอย่าง
การคัดลอกรหัสมีดังนี้:
-
-
-
'// จาก codeproject.com
'// คำนวณรหัส JS และ ASP
'// แก้ไข bluedestiny
'//mail:bluedestinyat126.com
-
-
ตัวเลือก Explicit
Response.buffer = FALSE
classcount_code
Privatefso, spath
privateasplines, jslines, aspbytes, jsbytes, aspwords
Privatesubclass_initialize
setfso = createObject ("Scripting.filesystemObject")
enddub
privateSubclass_terminate
setfso = ไม่มีอะไร
enddub
PrivateFunctionIterate (เส้นทาง)
Dimfolder, โฟลเดอร์, ไฟล์, ไฟล์, ts, txt, arr, f
setFolder = fso.getFolder (เส้นทาง)
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"
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 = folder.subfolders
foreachfinfolders
iteratef.path
ต่อไป
endfunction
PublicPropertyleTpath (s)