The translator's words:
I don't know if I have the same feelings with me. The most headache in the ASP is that it is inconvenient when debugging the program. I think many friends will use this method "response.write", then output related The statement is to see if it is correct. A few days ago, I wrote a thousand pages. There were probably seven eight sub / functions. I used more than 30 response.write, the day, and the thirty one was deleted after debugging. !
I saw the Debug class (VBS) in an ASP today, trying to!
The method is very simple:
Test.asp <% outpr =" xxxx "set debugstr = new debuggingconsole debugstr.enabled = true debugstr.print" Value of the parameter OUTPUT ", Output '... Debugstr.draw set debugstr = Nothing%> =========================================== ========== Debuggingconsole.asp <% class debuggingconsole
private dbg_Enabled private dbg_Show private dbg_RequestTime private dbg_FinishTime private dbg_Data private dbg_DB_Data private dbg_AllVars private dbg_Show_default private DivSets (2) 'Construktor => set the default values Private Sub Class_Initialize () dbg_RequestTime = Now () dbg_AllVars = false Set dbg_Data = Server.CreateObject ( " Scripting.dictionary ") DivSets (0) ="
Div id = data # sectname # style = "" Cursor: text; display: block; background: #ffff; padding-left: 8; "οnclick =" "" οnclick = "" "οnclick =" "" οnclick = "" Window.Event.cancelbubble = true; ""> | #data # | Div> | div> | "DivSets (2) ="
'@Param: - label [string]: description of the variable' '@Param: - Output [variable]: The variable itself' ********************************** *********************************************************** ***************************************************** Public Sub Print (label, Output IF DBG_ENABED 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 Do IF Not DBG_DATA.EXISTS (LBL) THEN EXIT DO I = I 1 LBL = Label & "(" & I & ")" LOOP Until i = i validlabel = lbl end funct ION '************************************************ *********************************************************** *************** '* PrintCookiesInfo' **************************************** *********************************************************** ******************************************** Private Sub PrintCookiesInfo (Byval Divsetno) DIM TBL, Cookie, Key, TMP for Each cookie 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 (KEY)) NEXT END IF NEXT TBL = MakeTable (TBL) if Request.Cookies.count <= 0 THEN DIVSETNO = 2 TMP = Replace (Replace (Divsetno), "# Sectname # "," Cookies ")," # title # "," cookies ")," # data # ", tbl) response.write replace (TMP," | ", vbrlf) end sub '******* *********************************************************** *********************************************************** ******* '* PrintsumMaryInfo' *************************************************** *********************************************************** *********************************** Private Sub PrintsumMaryInfo (Byval Divsetno) DIM TMP, TBL TBL = AddRow (TBL, "Time of Request", DBG_RequestTime) tbl = AddRow (tbl, "Elapsed Time", DateDiff ( "s", dbg_RequestTime, dbg_FinishTime) & "seconds") tbl = AddRow (tbl, "Request Type", Request.ServerVariables ( "REQUEST_METHOD")) tbl = AddRow ( TBL, "STATUS CODE", response.status TBL = AddRow (TBL, "Script Engine", Scriptengine & "& scriptenginemajorversion &". "& scriptengineminorversion &". " & Scriptenginebuildversion) TBL = MakeTable (TBL) TMP = Replace (Replace (DivSets (Divsetno), "# Sectname #", "Summary", "# Title #", "Summary Info", "# data #" , TBL) Response.Write Replace (TMP, "|", VBCRLF) End Sub '**************************************** *********************************************************** **************************************** '' @sdescription: adds the database-connection object to the debug-instance. To Display Database-Information '' @
PARM: - 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, "OLEDB VER", OSQLDB.Properties ("OLE DB VERSION")) DBG_DB_DATA = AddRow (DBG_DB_DATA, "DBMS", OSQLDB.Properties ("DBMS Name" & "Ver:" & OSQLDB.Properties (" DBMS Version ")) 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 IBJECT (Collection) and Name <> "Server Variables" and name <> "QueryString" and name <> "form" TBL = AddRow (TBL, VITEM, "{Object}") Elseif Isnull (Collection (VITEM)) TBL = AddRow (TBL , VITEM, "{null}") Elseif Isarray (Collection) THEN TBL = AddRow (TBL, VITEM, "{Array}) ELSE IF DBG_ALLVARS THEN TBL = AddRow (TBL," *********************************************************** *********************************************************** ************* '* Addrow' **************************************** *********************************************************** ****************************************** Private Function Addrow (Byval T, Byval Var, Byval Val) T = T & " |
TR> "& Extrainfo 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 '
| "& Var &" | = "& Val &" | tr> "Addrow = T end function" ********** *********************************************************** *********************************************************** *** '* MakeTable' ************************************************************* *********************************************************** ******************************* Private Function MakeTable (Byval Tdata) TDATA = "|