I think many friends may use this method "response.write" and then output relevant statements to see if it is correct. A few days ago, I wrote a thousand lines page, which contains about seven or eight SUB/FUNCTIONs. I used more than thirty responses.write when debugging. Oh my God, after debugging, delete these thirty one by one, which is tiring!
Today I saw a Debug class (VBS) in ASP. I tried it out, it was amazing!
How to use is very simple:
test.asp
The code copy is as follows:
<!--#INCLUDE FILE="debuggingConsole.asp"-->
<%
output="XXXX"
Set debugstr = New debuggingConsole
debugstr.Enabled = true
debugstr.Print "Value of parameter output", output
'...
debugstr.draw
Set debugstr = Nothing
%>
======================================================================
debuggingConsole.asp
The code copy is as follows:
<%
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) = "<TR><TD style='cursor:hand;' onclick=""javascript:if (document.getElementById('data#sectname#').style.display=='none'){document.getElementById('data#sectname#').style.display='block';}else{document.getElementById('data#sectname#').style.display='none';}""><DIV id=sect#sectname# style=""font-weight:bold;cursor:hand;background:#7EA5D7;color:white;padding-left:4;padding-right:4;padding-bottom:2;"">|#title#| <DIV id=data#sectname# style=""cursor:text;display:none;background:#FFFFF;padding-left:8;"" onclick=""window.event.cancelBubble = true;">|#data#| </DIV>|"
DivSets(1) = "<TR><TD><DIV id=sect#sectname# style=""font-weight:bold;cursor:hand;background:#7EA5D7;color:white;padding-left:4;padding-right:4;padding-bottom:2;"" onclick=""javascript:if (document.getElementById('data#sectname#').style.display=='none'){document.getElementById('data#sectname#').style.display='block';}else{document.getElementById('data#sectname#').style.display='none';}"">|#title#| <DIV id=data#sectname# style=""cursor:text;display:block;background:#FFFFF;padding-left:8;"" onclick=""window.event.cancelBubble = true;"">|#data#| </DIV>|</DIV>|"
DivSets(2) = "<TR><TD><DIV id=sect#sectname# style=""background:#7EA5D7;color:lightsteelblue;padding-left:4;padding-right:4;padding-bottom:2;"">|#title#| <DIV id=data#sectname# style=""display:none;background:lightsteelblue;padding-left:8"">|#data#| </DIV>|"
dbg_Show_default = "0,0,0,0,0,0,0,0,0,0,0,0,0,0"
End Sub
Public Property Let Enabled(bNewValue) ''[bool] Sets "enabled" to true or false