欢迎光临
我们一直在努力

加亮显示ASP文章原代码

建站超值云服务器,限时71元/月

<%@ 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

%>

<html>

<head>

<meta name="description" content="asp source code browser">

<meta name="generator" content="microsoft frontpage 3.0">

<meta http-equiv="content-type" content="text/html; charset=iso8859-1">

<title></title>

</head>

<body bgcolor="#ffffff" topmargin="0" leftmargin="0" alink="#23238e" vlink="#808080"

link="#ffcc00">

<basefont face="verdana, arial, helvetica" size="2"><!— display the color legend —>

<table border="1">

<tr>

<td width="25" bgcolor="#ff0000">&nbsp;&nbsp; </td>

<td><font face="verdana, arial, helvetica" size="2">asp script</font> </td>

</tr>

<tr>

<td bgcolor="#0000ff">&nbsp;&nbsp; </td>

<td><font face="verdana, arial, helvetica" size="2">comments</font> </td>

</tr>

<tr>

<td bgcolor="#000000">&nbsp;&nbsp; </td>

<td><font face="verdana, arial, helvetica" size="2">html and text</font> </td>

</tr>

</table>

<hr>

<font face="verdana, arial, helvetica" size="2"><% outputsource %>

</font>

</body>

</html>

<%

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 "<br>"

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("&nbsp;")

next

end if

ipos = instr(strline, "<")

if ipos then

response.write(left(strline, ipos – 1))

response.write("&lt;")

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("<font color=#ff0000>")

response.write("&lt;%")

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("%&gt;")

response.write("</font>")

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("<font color=#0000ff>")

response.write("&lt;script")

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("&lt;/script&gt;")

response.write("</font>")

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("<font color=#0000ff>")

response.write("&lt;!–")

strline = right(strline, len(strline) – (ipos + 3))

call printline(strline, fcheckline(strline))

case 6

ipos = instr(1, strline, "-" & "->", 1)

call printhtml(left(strline, ipos – 1))

response.write("–&gt;")

response.write("</font>")

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

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 加亮显示ASP文章原代码
分享到: 更多 (0)