VBS、ASP代码语法加亮显示的类

2019-01-14 04:34:33于海丽

' Grab the time at the completion of processing
m_EndTime = Time()

' Close the outside table
Response.Write "</PRE></td></tr></table>"

' Close the file and destroy the file object
objFile.close
Set objFile = Nothing
End Sub

' This function parses a line character by character
Private Function CharacterParse(inLine)
Dim charBuffer, tempChar, i, outputString
Dim insideString, workString, holdChar

insideString = False
outputString = ""

For i = 1 to Len(inLine)
tempChar = mid(inLine, i, 1)
Select Case tempChar
Case " "
If Not insideString Then
charBuffer = charBuffer & " "
If charBuffer <>" " Then
If left(charBuffer, 1) = " " Then outputString = outputString & " "

' Check for a 'rem' style comment marker
If LCase(Trim(charBuffer)) = "rem" Then
outputString = outputString & CommentColor
outputString = outputString & "REM"
workString = mid( inLine, i, Len(inLine))
workString = replace(workString, "<", "&lt;")
workString = replace(workString, ">", "&gt;")
outputString = outputString & workString & "</font>"
charBuffer = ""
Exit For
End If

outputString = outputString & FindReplace(Trim(charBuffer))
If right(charBuffer, 1) = " " Then outputString = outputString & " "
charBuffer = ""
End If
Else
outputString = outputString & " "
End If
Case "("
If left(charBuffer, 1) = " " Then
outputString = outputString & " "
End If
outputString = outputString & FindReplace(Trim(charBuffer)) & "("
charBuffer = ""
Case Chr(60)
outputString = outputString & "<"
Case Chr(62)
outputString = outputString & ">"
Case Chr(34)
' catch quote chars and flip a boolean variable to denote that
' whether or not we're "inside" a quoted string
insideString = Not insideString
If insideString Then
outputString = outputString & StringColor
outputString = outputString & "&quot;"
Else
outputString = outputString & """"
outputString = outputString & "</font>"
End If
Case "'"
' Catch comments and output the rest of the line
' as a comment IF we're not inside a string.
If Not insideString Then
outputString = outputString & CommentColor
workString = mid( inLine, i, Len(inLine))
workString = replace(workString, "<", "&lt;")
workString = replace(workString, ">", "&gt;")
outputString = outputString & workString
outputString = outputString & "</font>"
Exit For
Else
outputString = outputString & "'"
End If
Case Else
' We've dealt with special case characters so now
' we'll begin adding characters to our outputString
' or charBuffer depending on the state of the insideString
' boolean variable
If insideString Then
outputString = outputString & tempChar
Else
charBuffer = charBuffer & tempChar
End If
End Select
Next