ASP in the most headaches is the debugging process is inconvenient, I think many friends will use such a method "Response.Write", and then output related statements to see whether the correct. A few days ago wrote a thousands of lines of the page, there are about seven or eight sub/function, debugging when the use of more than 30 Response.Write, days, debugging after the 30 deleted one after another, tired!
Today see an ASP in the Debug Class (VBS), a try, absolutely!
The use method is simple:
Test.asp
<!--#INCLUDE file= "debuggingconsole.asp"-->
<%
output= "XXXX"
Set debugstr = New debuggingconsole
Debugstr. Enabled = True
Debugstr. Print "parameter output value", Output
''......
Debugstr.draw
Set debugstr = Nothing
%>
Public Property Let-Enabled (bnewvalue) ' [bool] Sets ' Enabled ' to true or false
dbg_enabled = Bnewvalue
End Property
Public Property Get Enabled ' [bool] Gets the ' enabled ' value
Enabled = dbg_enabled
End Property
Public Property Let Show (Bnewvalue) ' [string] Sets the debugging panel. Where each digit in the string represents a debug information pane in order (one of the them). 1=open, 0=closed
Dbg_show = Bnewvalue
End Property
Public Property Get Show ' [string] Gets the debugging panel.
Show = Dbg_show
End Property
Public Property Let Allvars (Bnewvalue) ' "[bool] Sets wheather All variables would be displayed or not. True/false
Dbg_allvars = Bnewvalue
End Property
Public Property Get Allvars ' "[bool] Gets If all variables would be displayed.
Allvars = Dbg_allvars
End Property
''************************************************************************************************************* *****
' @SDESCRIPTION: Adds A variable to the debug-informations.
' @PARAM:-label [string]: Description of the variable
' @PARAM:-Output [variable]: the variable itself
''************************************************************************************************************* *****
Public Sub Print (label, output)
If dbg_enabled Then
If Err.Number > 0 Then
Call Dbg_data.add Validlabel (label), "!!! Error: "& Err.Number &" "& Err. Description)
Err. Clear
Else
UniqueID = Validlabel (label)
Response.Write UniqueID
Call Dbg_data.add (UniqueID, Output)
End If
End If
End Sub
''************************************************************************************************************* *****
"* Validlabel
''************************************************************************************************************* *****
Private Function Validlabel (ByVal label)
Dim i, LbL
i = 0
LBL = Label
Todo
If not dbg_data.exists (LBL) then Exit Do
i = i + 1
LBL = label & "(& I &)"
Loop Until I = i
Validlabel = LBL
End Function
''************************************************************************************************************* *****
"* Printcookiesinfo
''************************************************************************************************************* *****
Private Sub Printcookiesinfo (ByVal divsetno)
Dim tbl, Cookie, key, TMP
For all cookies in Request.Cookies
If not Request.Cookies (cookie). HasKeys Then
TBL = AddRow (tbl, Cookie, request.cookies (cookie))
Else
For each key in Request.Cookies (cookie)
TBL = AddRow (tbl, Cookie & "(" & Key & "), Request.Cookies (cookie) (key)
Next
End If
Next
TBL = maketable (TBL)
If Request.Cookies.count <= 0 Then Divsetno = 2
TMP = replace (replace (Divsets (Divsetno), "#sectname #", "Cookies"), "#title #", "Cookies"), "#data #", TBL)
Response.Write Replace (tmp, "|", vbCrLf)
End Sub
''************************************************************************************************************* *****
' @SDESCRIPTION: Adds the Database-connection object to the debug-instance. To display Database-information
' @PARAM:-Osqldb [Object]: Connection-object
''************************************************************************************************************* *****
Public Sub Grabdatabaseinfo (ByVal osqldb)
Dbg_db_data = AddRow (Dbg_db_data, "ADO Ver", osqldb.version)
Dbg_db_data = AddRow (dbg_db_data, OLE DB Ver, Osqldb.properties ("OLE DB Version"))
Dbg_db_data = AddRow (Dbg_db_data, DBMS, Osqldb.properties ("DBMS Name") & "Ver:" & Osqldb.properties ("DBMS vers Ion "))
Dbg_db_data = AddRow (Dbg_db_data, "Provider", Osqldb.properties ("Provider Name") & "Ver:" & Osqldb.properties (" Provider Version "))
End Sub
''************************************************************************************************************* *****
"* Printdatabaseinfo
''************************************************************************************************************* *****
Private Sub Printdatabaseinfo (ByVal divsetno)
Dim tbl
TBL = maketable (dbg_db_data)
TBL = replace (replace (Divsets (Divsetno), "#sectname #", "Database"), "#title #", "Database INFO"), "#data #", TBL)
Response.Write Replace (TBL, "|", vbCrLf)
End Sub
''************************************************************************************************************* *****
"* printcollection
''************************************************************************************************************* *****
Private Sub printcollection (Byval Name, Byval Collection, Byval Divsetno, Byval ExtraInfo)
Dim Vitem, TBL, Temp
For each vitem in Collection
If IsObject (Collection (Vitem)) and name <> "SERVER VARIABLES" and name <> "QueryString" and name <> "for M "Then
TBL = AddRow (TBL, Vitem, "{object}")
ElseIf IsNull (Collection (vitem)) Then
TBL = AddRow (TBL, Vitem, "{null}")
ElseIf IsArray (Collection (vitem)) Then
TBL = AddRow (TBL, Vitem, "{array}")
Else
If Dbg_allvars Then
TBL = AddRow (TBL, "<nobr>" & Vitem & "</nobr>", server. HTMLEncode (Collection (Vitem))
ElseIf (Name = "SERVER VARIABLES" and Vitem <> "All_http" and Vitem <> "All_raw") or Name <> "Server VAR" Iables "Then
If Collection (vitem) <> "" Then
TBL = AddRow (TBL, Vitem, server. HTMLEncode (Collection (Vitem))) ' & ' {& TypeName (Collection (Vitem)) & "}"
Else
TBL = AddRow (TBL, Vitem, "...")
End If
End If
End If
Next
If ExtraInfo <> "" Then tbl = tbl & "<tr><td colspan=2>TBL = maketable (TBL)
If Collection.count <= 0 then Divsetno =2
TBL = replace (replace (Divsets (Divsetno), "#title #", Name), "#data #", TBL)
TBL = replace (TBL, "#sectname #", replace (Name, "", ""))
Response.Write Replace (TBL, "|", vbCrLf)
End Sub
''************************************************************************************************************* *****
"* AddRow
''************************************************************************************************************* *****
Private Function AddRow (ByVal T, ByVal Var, ByVal Val)
t = t & "|<tr valign=top>|<td>|" & var & "|<td>=" & Val & "|</tr>"
AddRow = t
End Function
''************************************************************************************************************* *****
"* maketable
''************************************************************************************************************* *****
Private Function Maketable (ByVal tdata)
Tdata = "|<table border=0 style=" "Font-size:10pt;font-weight:normal;" > "+ tdata +" </table>| "
Maketable = Tdata
End Function
''************************************************************************************************************* *****
"' @SDESCRIPTION: Draws the Debug-panel
''************************************************************************************************************* *****
Public Sub Draw ()
If dbg_enabled Then
Dbg_finishtime = Now ()
Dim Divset, X
Divset = Split (Dbg_show_default, ",")
Dbg_show = Split (Dbg_show, ",")
For x = 0 To UBound (dbg_show)
Divset (x) = Dbg_show (x)
Next
"' destructor
Private Sub Class_Terminate ()
Set Dbg_data = Nothing
End Sub
End Class
%>
Description of Class:
CLASS Debuggingconsole
version:1.2
Public Properties
Property Let Enabled (Bnewvalue) [bool] Sets ' Enabled ' to true or false
Property Get Enabled [bool] Gets the ' enabled ' value
Property Let Show (Bnewvalue) [string] Sets the debugging panel. Where each digit in the string represents a debug information pane in order (one of the them). 1=open, 0=closed
Property Get Show [string] Gets the debugging panel.
Property Let Allvars (Bnewvalue) [bool] Sets wheather All variables'll be displayed or not. True/false
Property Get Allvars [bool] Gets If all variables would be displayed.
Public Methods
Public Sub Print (label, output)
Adds a variable to the debug-informations.
Public Sub Grabdatabaseinfo (ByVal osqldb)
Adds the Database-connection object to the debug-instance. To display Database-information
Public Sub Draw ()
Draws the Debug-panel
Methods Detail
Public Sub Print (label, output)
Parameters:-Label [string]: Description of the variable
-Output [variable]: the variable itself
Public Sub Grabdatabaseinfo (ByVal osqldb)
Parameters:-Osqldb [Object]: Connection-object
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.