查看完整版本: VBS、ASP代码语法加亮显示的类(2)

豹子 2007-6-23 10:29

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

!--#include file="token.asp"--G2Vy;D$V!X
% ' *************************************************************************
3U-\7Inwge:Tbn$LE ' This is all test/example code showing the calling syntax of the )@$_$?A.Dk fV5r/qgE
' cBuffer class ... the interface to the cBuffer object is quite simple.
J}p_P '-{RM:Vm4B4s
' Use it for reference ... delete it ... whatever.
#zZ4k-ac$u8vb ' *************************************************************************
~c[ Y\!b.k E(G
`6`6B U-Cf?jj   
4tc Y*Q1bs9l
}&MH9o8X5mWkZ REM This is a rem type comment just for testing purposes!  W/e3J(]"h#i

2Q3T;{*n ] ' This variable will hold an instance of the cBuffer class
;[)MJ)ug#U5x6r Dim objBuffer  U[sD` Hj

+m y&fU%\/C\:F0b ' Set up the error handling*Ff#g~*cr
On Error Resume Next  
m~5Ty|
[W$TS4YT6b%r,O ' create the instance of the cBuffer classc1yaQN`X
Set objBuffer = New cBuffer/S]Mc qV3}
&iqCEOIILq}
' Set the PathToFile property of the cBuffer class
"Ne5YcA jGP '0b5^6alDq0EV
' Just for kicks we'll use the asp file that we created
7{ dx ZB.n%@}Vk ' in the last installment of this article series for testing purposesqP B8MqI
objBuffer.PathToFile = "../081899/random.asp" '这是文件名啦。  
(H:K+n(N-[*c
^^0_"K%L&g`o ' Here's an example of how to add a new keyword to the keyword array/HGey.]3c5_
' You could add a list of your own function names, variables or whatever...cool!
H:bN.RI P},q ' NOTE: You can add different HTML formatting if you like, the strongnX%iK |J_|V
' attribute will applied to all keywords ... this is likely to changesz!g _h1@7J
' in the near future.1b F1Vto%pIZ
'
E\F_,F 'objBuffer.AddKeyword "response.write", "font color=RedResponse.Write/font"
SL)dP@ D*]cZ 1y.S K`SC$Y
' Here are examples of changing the table background color, code color,
-B~ ez$o ' comment color, string color and tab space propertiesO#oJ@T#g!p$tX%Tg
'
0a.Q7N yz 'objBuffer.TableBGColor = "LightGrey" ' or}S d|%X9C3g6@9F
'objBuffer.TableBGColor = "#ffffdd" ' simple right?{J3L8m-lNIj?$Ic
'objBuffer.CodeColor = "Red"VI2Z*w f(dS%C,Xev?
'objBuffer.CommentColor = "Orange"
9[X@Z:Lr 'objBuffer.StringColor = "Purple"p-@%U*o6z Wa*Q
'objBuffer.TabSpaces = " "
&M:u;Gdb-F h:U
hz3Ut_ l&E$z_ ' Call the ParseFile method of the cBuffer class, pass it true if you want the
bU8Cy"A9G/r%m@p7x ' HTML contained in the page output or false if you don't)h4i&sR7f D {(zq:V
objBuffer.ParseFile False '注意:显示代码的response.write已经在class中。这里调用方法就可以了。  
(Wb0`Z'bc*nF O
Eq|&o1w:hW%?   
+C4Q O&s)Dp4Ut0jH BV*U-xTQ g_
vyR!cNv
' Check for errors that may have been raised and write them out{_JK%Jd{K
If Err.number  0 Then
GD Cp2I ? Response.Write Err.number  ":"  Err.description  ":"  Err.source  "br"Vc? f8WnB @
End If  8DLi+}Q3NZ

*Q-m[V;? ' Output the processing time and number of lines processed by the script
!]Fc+HK9Oy Response.Write "strongProcessing Time:/strong "  objBuffer.ProcessingTime  " secondsbr"@(tB(F+I]"{
Response.Write "strongLines Processed:/strong "  objBuffer.LineCount  "br"   
N!F6zqD2V (\ V@@H"K
' Destroy the instance of our cBuffer class
5a,c3n~,L,RK(d4] Set objBuffer = Nothing^2Y1Vt+x\|#N[+D.P
%
页: [1]
查看完整版本: VBS、ASP代码语法加亮显示的类(2)