ASP Listing Output to Web

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/66869?pagenum=1
05 November 2025, 10:13

Topic


Carefree
ASP Listing Output to Web
15 April 2008, 22:09


Seems like about two years ago, there was a mod that would let you specify any asp page and it could be viewed (with line numbers) on the web. This did not require saving as .txt or anything else. Does anyone else remember this one?
I've searched about 10 different ways here and struck out.<

 

Replies ...


muzishun
15 April 2008, 22:44


I adapted some code several years ago for this. Here is the original topic. I don't have the backup files from that site handy (it no longer exists), but I will check them tomorrow and see if I can track down the vsrc.asp file used in the MOD.<
Carefree
16 April 2008, 00:16


I found a viewsource asp file on asp101.com. Here's the output of viewsource.asp applied to itself:
Code:

<strong>ASP Source Code:</strong>
<hr />
<%
Dim objFSO, objInFile
Dim strIn, strTemp
Dim I, J
Dim strFileName
Dim ProcessString
Dim bCharWritten
Dim bInsideScript
Dim bInsideString
Dim iInsideComment

ProcessString = 0
bCharWritten = False
bInsideScript = False
bInsideString = False
iInsideComment = 0

strFileName = Request.QueryString("file")

' Conditional limiting use of this file
If InStr(1, strFileName, "\", 1) Then strFileName=""
If InStr(1, strFileName, "/", 1) Then strFileName=""

strFileName = Replace(strFileName, "%2E", ".")
strFileName = Replace(strFileName, "%5F", "_")

If strFileName <> "" Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objInFile = objFSO.OpenTextFile(Server.MapPath(strFileName))

Response.Write "<PRE>" & vbCRLF
' Loop Through Real File and Output Results to Browser
Do While Not objInFile.AtEndOfStream
strIn = Server.HTMLEncode(objInFile.ReadLine)
' If we find Begin Script Tag start processing
If InStr(1, strIn, "<!-- BEGIN SCRIPT -->", 1) Then
ProcessString = 1
strIn = Server.HTMLEncode(objInFile.ReadLine)
End If
' If we find End Script Tag stop processing
If InStr(1, strIn, "<!-- END SCRIPT -->", 1) Then ProcessString = 0

If ProcessString = 1 Then
strTemp = ""
For I = 1 to Len(strIn)
bCharWritten = False
If InStr(I, strIn, "<%", 1) = I Then
strTemp = strTemp & "<FONT COLOR=#0000FF>"
bInsideScript = True
Else
If InStr(I, strIn, "%>", 1) = I Then
strTemp = strTemp & "%></FONT>"
bCharWritten = True
' so we dont get the trailing end of this tag again! ' ie. Len("%>") - 1 = 4
I = I + 4
bInsideScript = False
End If
End If
' Toggle Inside String if needed! If bInsideScript And iInsideComment = 0 And InStr(I, strIn, """, 1) = I Then bInsideString = Not bInsideString
' Now do comments if we're in script
If bInsideScript And Not bInsideString And InStr(I, strIn, "'", 1) = I Then
strTemp = strTemp & "<FONT COLOR=#009900>"
iInsideComment = iInsideComment + 1
End If
' End comment at end of line if needed
If iInsideComment > 0 And I = Len(strIN) Then
strTemp = strTemp & Mid(strIn, I, 1)
For J = 1 to iInsideComment
strTemp = strTemp & "</FONT>"
Next 'J
bCharWritten = True
iInsideComment = 0
End If
If bCharWritten = False Then
strTemp = strTemp & Mid(strIn, I, 1)
End If
Next
Response.Write strTemp & vbCRLF
End If
Loop
Response.Write "</PRE>" & vbCRLF

objInFile.Close
Set objInFile = Nothing
Set objFSO = Nothing
Else
strFileName = "index.asp"
End If
%>
Don't know if it's even close to that one from 2004, my memory is playing tricks on me. If you don't find the original, maybe there's a way we can adapt this one.<
Carefree
16 April 2008, 00:32


Carefree
16 April 2008, 01:01


OK - I eliminated the mods pertinent to Oxle & Crash's portal, have what I need except for the line numbering ability.
<
MarcelG
16 April 2008, 04:04


Carefree ; I'll have to retrieve the file later today (I'm currently at work, and cannot FTP to the outside world....)<
Shaggy
16 April 2008, 04:29


Carefree, please refrain from posting the entire contents of files here, instead link to a *.txt or zipped copy of the file.
<
AnonJr
16 April 2008, 13:32


Or at the very least use the [scrollcode] tags...<
MarcelG
16 April 2008, 14:17


Carefree ; here it is: http://oxle.com/source.txt<
Carefree
21 April 2008, 17:35


Sorry about not scrolling, mind on too many things.
Thanks, Marcel.<
AnonJr
21 April 2008, 18:09


Originally posted by Carefree
Sorry about not scrolling, mind on too many things.
Understandable. It just gets annoying to have to scroll on a monitor that's set to 1600x1200 wink<
© 2000-2021 Snitz™ Communications