Count Lines in Pages

Contents of Page: DisplayPageContents.asp Number of Lines: 73 Last Modified: 2/20/2026 1:30:23 PM
0001: <% @Language = "VBScript" %>
0002: 
0003: <!-- #include FILE="include/adovbs.inc" -->
0004: <!-- #include FILE="include/constants.inc" -->
0005: <!-- #include FILE="include/funcs.asp" -->
0006: <!-- #include FILE="include/ReturnPageSet.inc" -->
0007: 
0008: <%
0009: 
0010: Pagename = Request.QueryString("PageName")
0011: Lines = Request.QueryString("Lines")
0012: 
0013: Dim fso, file, lineNum, filePath
0014: 
0015: filePath = Server.MapPath(Pagename) ' change to your file
0016: 
0017: Set fso = Server.CreateObject("Scripting.FileSystemObject")
0018: Set file = fso.OpenTextFile(filePath, 1) ' 1 = ForReading
0019: 
0020: Set fileInfo = fso.GetFile(filePath)
0021: 
0022: 
0023: LastChanged = fileInfo.DateLastModified
0024: 
0025: %>
0026: 
0027: <html>
0028: 
0029: <head>
0030: 	<title>Count Lines in Pages</title>
0031: 	<link href="mm.css" rel="stylesheet" type="text/css">
0032: 	<link href="desb.css" rel="stylesheet" type="text/css">	
0033: <meta name="viewport" content="width=device-width">
0034: 
0035: 
0036: </head>
0037: <table cellspacing="1" border="0" cellpadding="5" width="80%" height="53">
0038: <tr>
0039:       
0040:       <td class="norm" colspan="10" align="center"><br><input type="button" class="button_close" value="Close Window" class="norm" onclick="window.close()"></td></td>
0041:  </tr>		
0042: 
0043: </table>
0044: 
0045: <table cellspacing="1" border="1" cellpadding="5" width="100%" height="53">
0046: <tr height="35">
0047: <td class="norm">
0048: <big>Contents of Page:  <b><%= PageName %></b></td>
0049: <td class="norm"> Number of Lines: <b><%= Lines %></b></td>
0050: <td class="norm">  Last Modified: <b><%= LastChanged %></b></td>
0051: </tr>
0052: <tr><td colspan="4">
0053: 
0054: <%
0055: lineNum = 1
0056: 
0057: 
0058: Response.Write "<pre>"
0059: 
0060: Do Until file.AtEndOfStream
0061:     Response.Write Right("0000" & lineNum, 4) & ": <small>" & Server.HTMLEncode(file.ReadLine) & "</small>" & vbCrLf
0062:     lineNum = lineNum + 1
0063: Loop
0064: 
0065: Response.Write "</pre>"
0066: 
0067: file.Close
0068: Set file = Nothing
0069: Set fso = Nothing
0070: %>
0071: </td>
0072: </tr>
0073: </table>