% '******************************************************* '* ASP 101 Sample Code - http://www.asp101.com/ * '* * '* This code is made available as a service to our * '* visitors and is provided strictly for the * '* purpose of illustration. * '* * '* http://www.asp101.com/samples/license.asp * '* * '* Please direct all inquiries to webmaster@asp101.com * '******************************************************* %> ASP Source Code:
" & vbCRLF ' Loop Through Real File and Output Results to Browser Do While Not objInFile.AtEndOfStream strIn = Server.HTMLEncode(objInFile.ReadLine) ' Check for start script comment If InStr(1, strIn, "<!-- BEGIN SCRIPT -->", 1) Then ProcessString = 1 strIn = Server.HTMLEncode(objInFile.ReadLine) End If ' Check for end script comment If InStr(1, strIn, "<!-- END SCRIPT -->", 1) Then ProcessString = 0 ' If we're on a line to be processed then do so If ProcessString = 1 Then strTemp = "" ' Loop through line For I = 1 to Len(strIn) ' First look for script openers to start red If InStr(I, strIn, "<%", 1) = I Then strTemp = strTemp & "" & Mid(strIn, I, 1) Else ' If no script openers look for closers to end red If InStr(I, strIn, "%>", 1) = I Then strTemp = strTemp & "%>" I = I + 4 Else ' If neither just copy to strTemp as is strTemp = strTemp & Mid(strIn, I, 1) End If End If Next ' Output out processed line Response.Write strTemp & vbCRLF End If Loop Response.Write "" & vbCRLF ' Close file and free variables objInFile.Close Set objInFile = Nothing Set objFSO = Nothing Else ' If they entered no filename or one with a / or \ ... deny access Response.Write "Sorry, but you do not have access to view files outside the current directory." End If %>