¡¾·±ÌåÖÐÎÄ¡¿
¡¾ÉèΪÊ×Ò³¡¿
¡¾¼ÓÈëÊղء¿
µ±Ç°Î»ÖãºASP¼¼ÊõÊ×Ò³ >> ½Å±¾±àÂë >> ¼ÓÁÁÏÔʾASPÎÄÕÂÔ­´úÂë

¼ÓÁÁÏÔʾASPÎÄÕÂÔ­´úÂë

2004-10-01 08:26:10  ×÷Õߣº  À´Ô´£º»¥ÁªÍø  ä¯ÀÀ´ÎÊý£º25  ÎÄ×Ö´óС£º¡¾´ó¡¿¡¾ÖС¿¡¾Ð¡¡¿
¼ò½é£º<%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit %> <% 'File: CodeBrws.asp 'Overview: This formats and writes the text of the selected page for ' ...
¹Ø¼ü×Ö£º¼ÓÁÁ ´úÂë ÎÄÕ ASP

<%@ LANGUAGE="VBSCRIPT" %>

<% Option Explicit %>

<%

'File: CodeBrws.asp

'Overview: This formats and writes the text of the selected page for

' the View Script Button

'This file is provided as part of the Microsoft Visual Studio 6.0 Samples

'THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT

'WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,

'INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES

'OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR

'PURPOSE.

'Copyright (C) 1997, 1998 Microsoft Corporation, All rights reserved

%>

LINK="#FFCC00">

ASP Script
Comments
HTML and Text


<% OutputSource %>

<%

Sub OutputSource

Dim strVirtualPath, strFilename

strVirtualPath = Request("Source")

strFilename = Server.MapPath(strVirtualPath)

Dim FileObject, oInStream, strOutput

'Creates a file object to hold the text of the selected page

Set FileObject = CreateObject("Scripting.FileSystemObject")

Set oInStream = FileObject.OpenTextFile(strFilename, 1, 0, 0)

'Loop that writes each line of text in the file according to

'the PrintLine function below

While NOT oInStream.AtEndOfStream

strOutput = oInStream.ReadLine

Call PrintLine(strOutput, fCheckLine(strOutput))

Response.Write "
"

Wend

End Sub

' Returns the minimum number greater than 0

' If both are 0, returns -1

Function fMin(iNum1, iNum2)

If iNum1 = 0 AND iNum2 = 0 Then

fMin = -1

ElseIf iNum2 = 0 Then

fMin = iNum1

ElseIf iNum1 = 0 Then

fMin = iNum2

ElseIf iNum1 < iNum2 Then

fMin = iNum1

Else

fMin = iNum2

End If

End Function

Function fCheckLine (ByVal strLine)

Dim iTemp, iPos

fCheckLine = 0

iTemp = 0

iPos = InStr(strLine, "<" & "%")

If fMin(iTemp, iPos) = iPos Then

iTemp = iPos

fCheckLine = 1

End If

iPos = InStr(strLine, "%" & ">")

If fMin(iTemp, iPos) = iPos Then

iTemp = iPos

fCheckLine = 2

End If

iPos = InStr(1, strLine, "<" & "SCRIPT", 1)

If fMin(iTemp, iPos) = iPos Then

iTemp = iPos

fCheckLine = 3

End If

iPos = InStr(1, strLine, "<" & "/SCRIPT", 1)

If fMin(iTemp, iPos) = iPos Then

iTemp = iPos

fCheckLine = 4

End If

iPos = InStr(1, strLine, "<" & "!--", 1)

If fMin(iTemp, iPos) = iPos Then

iTemp = iPos

fCheckLine = 5

End If

iPos = InStr(1, strLine, "-" & "->", 1)

If fMin(iTemp, iPos) = iPos Then

iTemp = iPos

fCheckLine = 6

End If

End Function

Sub PrintHTML (ByVal strLine)

Dim iPos, iSpaces, i

iSpaces = Len(strLine) - Len(LTrim(strLine))

i = 1

'Correct for tabs

While Mid(Strline, i, 1) = Chr(9)

iSpaces = iSpaces + 5

i = i + 1

Wend

'Insert spaces

If iSpaces > 0 Then

For i = 1 to iSpaces

Response.Write(" ")

Next

End If

iPos = InStr(strLine, "<")

If iPos Then

Response.Write(Left(strLine, iPos - 1))

Response.Write("<")

strLine = Right(strLine, Len(strLine) - iPos)

Call PrintHTML(strLine)

Else

Response.Write(strLine)

End If

End Sub

Sub PrintLine (ByVal strLine, iFlag)

Dim iPos

Select Case iFlag

Case 0

Call PrintHTML(strLine)

Case 1

iPos = InStr(strLine, "<" & "%")

Call PrintHTML(Left(strLine, iPos - 1))

Response.Write("")

Response.Write("<%")

strLine = Right(strLine, Len(strLine) - (iPos + 1))

Call PrintLine(strLine, fCheckLine(strLine))

Case 2

iPos = InStr(strLine, "%" & ">")

Call PrintHTML(Left(strLine, iPos -1))

Response.Write("%>")

Response.Write("")

strLine = Right(strLine, Len(strLine) - (iPos + 1))

Call PrintLine(strLine, fCheckLine(strLine))

Case 3

iPos = InStr(1, strLine, "<" & "SCRIPT", 1)

Call PrintHTML(Left(strLine, iPos - 1))

Response.Write("")

Response.Write("

strLine = Right(strLine, Len(strLine) - (iPos + 6))

Call PrintLine(strLine, fCheckLine(strLine))

Case 4

iPos = InStr(1, strLine, "<" & "/SCRIPT>", 1)

Call PrintHTML(Left(strLine, iPos - 1))

Response.Write("")

Response.Write("")

strLine = Right(strLine, Len(strLine) - (iPos + 8))

Call PrintLine(strLine, fCheckLine(strLine))

Case 5

iPos = InStr(1, strLine, "<" & "!--", 1)

Call PrintHTML(Left(strLine, iPos - 1))

Response.Write("")

Response.Write("")

Response.Write("")

strLine = Right(strLine, Len(strLine) - (iPos + 2))

Call PrintLine(strLine, fCheckLine(strLine))

Case Else

Response.Write("Function Error -- Please contact the administrator.")

End Select

End Sub

%>

ÔðÈα༭£ºadmin
±¾ÎÄÒýÓõØÖ·£º http://www.3pcode.com/asp/2004/10/4015.htm
Ïà¹ØÎÄÕÂ