您的位置:首页精文荟萃软件资讯 → 加亮显示ASP文章原代码转

加亮显示ASP文章原代码转

时间:2004/10/7 19:16:00来源:本站整理作者:蓝点我要评论(0)


            
             
              
             
            

               
               

            



            加亮显示ASP文章原代码
加入时间:2000年10月29日    来源网站:中华技术网
<%@ 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
%>

相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么

文章评论
发表评论

热门文章 360快剪辑怎么使用 36金山词霸如何屏幕取词百度收购PPS已敲定!3

最新文章 微信3.6.0测试版更新了微信支付漏洞会造成哪 360快剪辑怎么使用 360快剪辑软件使用方法介酷骑单车是什么 酷骑单车有什么用Apple pay与支付宝有什么区别 Apple pay与贝贝特卖是正品吗 贝贝特卖网可靠吗

人气排行 xp系统停止服务怎么办?xp系统升级win7系统方电脑闹钟怎么设置 win7电脑闹钟怎么设置office2013安装教程图解:手把手教你安装与qq影音闪退怎么办 QQ影音闪退解决方法VeryCD镜像网站逐个数,电驴资料库全集同步推是什么?同步推使用方法介绍QQ2012什么时候出 最新版下载EDiary——一款好用的电子日记本