<%
if Request.QueryString("file") <> ""
then
dim css
css = "http://www.jdmx.com/css/src.css"
Response.Write "<link rel=""stylesheet"" href=""" & css & """ />"
WriteASP(Request.QueryString("file"))
end if
function ReadFile(sfile)
dim fobj
dim file
dim s
set fobj = Server.CreateObject("Scripting.FileSystemObject")
if fobj.FileExists(sfile)
then
set file = fobj.OpenTextFile(sfile, 1)
if not file.AtEndOfStream
then
s = file.readall
end if
file.Close
end if
set fobj = nothing
ReadFile = s
end function
function ReplaceChar(byval sText, byval sFind, byval sReplace)
dim oQre
set oQre = new regexp
oQre.Pattern = sFind
oQre.Global = true
sText = oQre.Replace(sText, sReplace)
set oQre = nothing
ReplaceChar = sText
end function
function KeyWordASP()
dim s
s = "(
& "
if|
then|
else|
end|
for|
to|
next|
while|
loop|
with|" _
& "
function|
sub|
dim|
select|
case|
const|
set"
KeyWordASP = Split(s, ",")
end function
function KeyWordDelphi()
dim s
s = "(//.*[^\r\n])~<delphi class=""comment"">$1</delphi>," _
& "({[^}]*}.)~<delphi class=""comment"">$1</delphi>," _
& "(<delphi[^>]*>[^<>]*</delphi>)|(
& "~<delphi class=""text"">$1</delphi>," _
& "begin|
end|result|var|uses|
if|
then|
else|do|" _
& "
for|
to|
next|
while|
with|
function|procedure|" _
& "
select|
case|
const|program|try|catch|" _
& "finally|and|or|not"
KeyWordDelphi = Split(s, ",")
end function
function KeyWordJavascript()
dim s
s = "
if|
then|
else|{|}|
for|
while|
loop|
with|" _
& "
function|var|switch|
case|
const"
KeyWordJavascript = Split(s, ",")
end function
function KeyWordVB()
dim s
s = "(
& "
if,
then,
else,
end,
for,
to,
next,
while,wend,
loop,
with," _
& "
function,
sub,
dim,
select,
case,
const,
set"
KeyWordVB = Split(s, ",")
end function
function ReadASP(sfile)
ReadASP = ReadSrc(sfile, "ASP")
end function
function ReadDelphi(sfile)
ReadDelphi = ReadSrc(sfile, "DELPHI")
end function
function ReadJavaScript(sfile)
ReadDelphi = ReadSrc(sfile, "JAVASCRIPT")
end function
function ReadVB(sfile)
ReadVB = ReadSrc(sfile, "VB")
end function
sub WriteASP(sfile)
WriteSrc ReadSrc(sfile, "ASP")
end sub
sub WriteDelphi(sfile)
WriteSrc ReadSrc(sfile, "DELPHI")
end sub
sub WriteJavascript(sfile)
WriteSrc ReadSrc(sfile, "JAVASCRIPT")
end sub
sub WriteVB(sfile)
WriteSrc ReadSrc(sfile, "VB")
end sub
function ReadSrc(sfile, stype)
dim s
dim kw
dim i
s = ReadFile(sfile)
select case uCase(stype)
case "ASP" : kw = KeyWordASP
case "VB" : kw = KeyWordVB
case "DELPHI" : kw = KeyWordDelphi
case "JAVASCRIPT" : kw = KeyWordJavascript
case else : kw = ASPKeyWord
end select
stype = lCase(stype)
if s <> ""
then
s = ReplaceChar(s, "<", "<")
s = ReplaceChar(s, ">", ">")
for i = 0
to uBound(kw)
dim x
dim sfind
dim srep
x = Split(kw(i), "~")
if uBound(x) = 0
then
sfind = "(<" & stype & "[^>]*>[^<>]*</" & stype & ">)|\b(" & kw(i) & ")\b"
srep = "$1<" & stype & " class=""$2"">$2</" & stype & ">"
else
sfind = "(" & x(0) & ")"
srep = x(1)
end if
s = ReplaceChar(s, sfind, srep)
next
s = ReplaceChar(s, "<" & stype & "[^>]*></" & stype & ">", "")
end if
ReadSrc = s
end function
sub WriteSrc(s)
response.Write "<pre><div id=""src"">" & s & "</div></pre>"
end sub
%>