首页 > 编程 > ASP > 正文

ASP中令人震撼的Debug类(VBScript)

2024-05-04 11:06:15
字体:
来源:转载
供稿:网友
译者的话:

不知道用asp写代码的朋友是不是和我有一样的感受,asp中最头疼的就是调试程序的时候不方便,我想可能很多朋友都会用这样的方法“response.write ”,然后输出相关的语句来看看是否正确。前几天写了一个千行的页面,里面大概有七八个sub/function,调试的时候用了有三十几个response.write ,天,调试完后把这三十个一个个删除,累!

今天看到一个asp中的debug类(vbs),试用了一下,绝!

使用方法很简单:

test.asp

<!--#include file="debuggingconsole.asp"-->
<%
output="xxxx"
set debugstr = new debuggingconsole
debugstr.enabled = true
debugstr.print "参数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) = "<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:#ffffff;padding-left:8;"" onclick=""window.event.cancelbubble = true;"">|#data#| </div>|</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:#ffffff;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>|</div>|"
dbg_show_default = "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
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 (11 of 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 will be displayed or not. true/false
dbg_allvars = bnewvalue
end property
public property get allvars ''[bool] gets if all variables will 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(unique

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表