SoFunction
Updated on 2025-04-09

Statistics how many lines of JS and ASP code are there


<%
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\
'\\   From
'\\    Computing js and asp codes
'\\    Modify bluedestiny
'\\    mail:bluedestiny at 
'\\
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

option explicit
=false

class COUNT_CODE
 private fso,spath
 private asplines, jslines, aspbytes, jsbytes, aspwords
 private sub class_initialize
  set fso = createobject("") 
 end sub
 private sub class_terminate
  set fso=nothing
 end sub
 private function iterate(path)
  dim folder, folders, files, file, ts, txt, arr, f
  set folder = (path)
  set files = 
  dim rx, c
  set rx = new regexp
   = true
   = true
   = "  +"
  for each file in files
   if right(,4)=".asp" or right(,3)=".js" then
    set ts = 
    if  then txt = "" else txt = 
    
    txt = (txt," ")
    txt = replace(txt,vbcrlf&vbcrlf,vbcrlf)
    arr = split(replace(txt,vbcrlf," ")," ")
    aspwords = aspwords + ubound(arr)
    arr = split(txt,vbcrlf)
    if right(,4)=".asp" then
     asplines = asplines + ubound(arr)
     aspbytes = aspbytes + len(txt)
    else
     jslines = jslines + ubound(arr)
     jsbytes = jsbytes + len(txt)
    end if
   end if
  next
  set folders = 
  for each f in folders
   iterate 
  next
 end function

 public property let path(s)
  spath=(s)
 end property
 public sub count
  iterate(spath)
 end sub
 public sub printf
   "ASP:" & "<br/>"
   "Total Lines Coded: " & asplines & "<br/>"
   "Total Bytes: " & aspbytes & "" & "<br/>"
   "Total Individual Elements (words) Typed: " & aspwords & "<br/>"
   "JScript:" & "<br/>"
   "Total Lines Coded: " & jslines & "<br/>"
   "Total Bytes: " & jsbytes
 end sub
end class

'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\Sample code
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

dim o
set o=new COUNT_CODE
="bluedestiny/"


%>