Click to See Complete Forum and Search --> : Counting lines...


weee
01-08-2006, 02:58 AM
I'm showing the content of the page using FSO:


Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set infile = FSO.OpenTextFile(Server.MapPath("../HTML" & Request("fileName")))
Response.Write Replace( Server.HTMLEncode(infile.ReadAll), vbNewLine, "<br />" & vbNewLine )
infile.Close


I wonder how can I add a number (1, 2, 3, ect') next to every line of code?

Thanks!

russell_g_1
01-08-2006, 12:57 PM
i would suggest reading the file a line at a time and just adding the number in as you go along. like this

function displayfile(path)

dim fso,count,infile
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if fso.fileexists(path) then
Set infile = fso.OpenTextFile(path)
count = 1
do while not infile.atendofstream
Response.Write "<br>" & count & "&nbsp;" & Server.HTMLEncode(infile.ReadLine)
count = count + 1
loop
infile.Close
end if

end function

weee
01-08-2006, 01:16 PM
Cooool! Thanks.