|
Easy Debugging of Variables by Charles Carroll
This page demonstrates how you can
print several variables in one step without resorting to:
<%
response.write "fname=<b>" & fname &
"</b><br>"
response.write "lname=<b>" & lname &
"</b><br>"
response.write "x=<b>" & x &
"</b><br>"
response.write "y=<b>" & y &
"</b><br>"
%>
by taking advantage of VB Eval and
encapsulating it into a subroutine to do all the work for you.
filename=/learn/test/debug1.asp
<%option explicit%>
<html><head>
<title>debug1.asp</title>
</head><body bgcolor="#FFFFFF">
<%
dim fname,lname,x,y,counter,mysample
fname="Jennifer"
lname="Jones"
x=9
y=7
dim myarray(9)
for counter=0 to 8
myarray(counter)=counter
next
set mysample=server.CreateObject("Scripting.Dictionary")
mysample.Add "haircolor", "brown"
mysample.add "eyecolor" , "blue"
mysample.add "dateofbirth", "5/13/64"
debug(true)
Call ShowVars("fname,lname,x,y")
Call ShowArray(myarray,"myarray")
Call ShowDictionary(mysample,"mysample")
set mysample = nothing
%>
</body></html>
<!--#include file="lib_debug1.asp"-->
The library that does the work:
filename=/learn/test/lib_debug1.asp
<%
dim lib_debug1
FUNCTION debug(parmStat)
lib_debug1=parmStat
debug=lib_debug1
END FUNCTION
SUB ShowVars(parmVars)
If lib_debug1=false THEN
exit sub
END IF
dim myparameters,parmcount,counter,thisvar,strexec,strall
myparameters=SPLIT(parmVars,",")
parmcount=ubound(myparameters)
for counter=0 to parmcount
thisvar=myparameters(counter)
strexec=thisvar
strexec=eval(strexec)
strall=strall & "<b>" & thisvar & "</b>=" & strexec & "<br>"
next
response.write strall
END SUB
SUB ShowDictionary(parmdict,parmLabel)
If lib_debug1=false THEN
exit sub
END IF
DIM key
response.write "Dictionary:" & parmLabel & "<br>"
FOR EACH key IN parmdict
response.write " " & parmLabel & ".item(""" & key & """)=<b>" & parmdict.item(key) & "</b><br>"
NEXT
response.write "Dictionary display done:" & parmLabel & "<br>"
END SUB
SUB ShowArray(parmArray,parmLabel)
If lib_debug1=false THEN
exit sub
END IF
dim highcount, counter
response.write "Array:" & parmLabel & "<br>"
highcount=ubound(parmArray)
response.write parmLabel & " ubound=" & highcount & "<br>"
for counter=0 to highcount
response.write " " & parmLabel & "(" & counter & ")</b>="
response.write parmArray(counter) & "<br>"
next
END SUB
%>
 |  |  |
 |
There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too.
a $5 tip buys him lunch at McDonalds,
a $20 tip buys his kid Hitoshi a new computer game,
a $39 tip buys his daughter Michiko a few nice outfits.
See our donor list.
|  |
 |  |  |
|
|
|
|