<% ' Debugging code ' Return string with htmlencoded value of variable, ' or empty string if value can't be represented function debug_vv (var) select case vartype (var) case VBString: debug_vv = """" & server.htmlencode (var) & """" case VBInteger, VBLong, VBSingle, VBDouble, VBCurrency, VBDate, VBBoolean, VBDecimal, VBByte: debug_vv = server.htmlencode (var) case else: debug_vv = "" end select end function ' Return string with variable's type function debug_vt (var) select case vartype (var) case VBEmpty: debug_vt = "(Empty)" case VBNull: debug_vt = "(Null)" case VBInteger: debug_vt = "(Integer)" case VBLong: debug_vt = "(Long)" case VBSingle: debug_vt = "(Single)" case VBDouble: debug_vt = "(Double)" case VBCurrency: debug_vt = "(Currency)" case VBDate: debug_vt = "(Date)" case VBString: debug_vt = "(String)" case VBObject: debug_vt = "(Object)" case VBError: debug_vt = "(Error)" case VBBoolean: debug_vt = "(Boolean)" case VBVariant: debug_vt = "(Variant)" case VBDataObject: debug_vt = "(DataObject)" case VBDecimal: debug_vt = "(Decimal)" case VBByte: debug_vt = "(Byte)" case VBArray: debug_vt = "(Array)" case 8204: debug_vt = "(Array)" case else: debug_vt = "(unknown: " & vartype (var) & "(" & typename (var) & "))" end select end function ' Return string with variable's value, or the type if value can't be represented function debug_var (var) dim v v = debug_vv (var) if v = "" then v = debug_vt (var) end if debug_var = v end function ' Return string with variable's type and value function debug_vartype (var) dim v, t t = debug_vt (var) v = debug_vv (var) if v <> "" then t = t & " " & v end if debug_vartype = t end function ' collection helper function function debug_collection (name, byref obj) dim item dim i, j, temp dim h dim keys redim keys (100) dim keycount ' read keys keycount = 0 for each item in obj keys (keycount) = item keycount = keycount + 1 if keycount > ubound (keys) then redim preserve keys (ubound (keys) * 2) end if next ' sort keys for i = 0 to keycount - 1 for j = i + 1 to keycount - 1 if keys (i) > keys (j) then temp = keys (i) keys (i) = keys (j) keys (j) = temp end if next next h = "

" & vbcrlf h = h & "" & vbcrlf h = h & " " & vbcrlf h = h & " " & vbcrlf for i = 0 to keycount - 1 item = keys (i) h = h & " " & vbcrlf next h = h & "
" & name & " (count = " & obj.count & ")
NameValue
" & server.htmlencode (item) & " " & debug_vartype (obj (item)) & "
" & vbcrlf debug_collection = h end function function debug_querystring debug_querystring = debug_collection ("querystring", request.querystring) end function function debug_form debug_form = debug_collection ("form", request.form) end function function debug_servervariables debug_servervariables = debug_collection ("servervariables", request.servervariables) end function function debug_cookies debug_cookies = debug_collection ("cookies", request.cookies) end function function debug_clientcertificate debug_clientcertificate = debug_collection ("clientcertificate", request.clientcertificate) end function function debug_sessionvars debug_sessionvars = debug_collection ("session vars", session.contents) end function ' Display field type text for a recordset field.type function debug_fieldtype (t) dim h h = "" select case t case 8192: h = "Array" case 20: h = "BigInt" case 128: h = "Binary" case 11: h = "Boolean" case 8: h = "BSTR" case 136: h = "Chapter" case 129: h = "Char" case 6: h = "Currency" case 7: h = "Date" case 133: h = "DBDate" case 137: h = "DBFileTime" case 134: h = "DBTime" case 135: h = "DBTimeStamp" case 14: h = "Decimal" case 5: h = "Double" case 0: h = "Empty" case 10: h = "Error" case 64: h = "FileTime" case 72: h = "GUID" case 9: h = "IDispatch" case 3: h = "Integer" case 13: h = "IUnknown" case 205: h = "LongVarBinary" case 201: h = "LongVarChar" case 203: h = "LongVarWChar" case 131: h = "Numeric" case 138: h = "PropVariant" case 4: h = "Single" case 2: h = "SmallInt" case 16: h = "TinyInt" case 21: h = "UnsignedBigInt" case 19: h = "UnsignedInt" case 18: h = "UnsignedSmallInt" case 17: h = "UnsignedTinyInt" case 132: h = "UserDefined" case 204: h = "VarBinary" case 200: h = "VarChar" case 12: h = "Variant" case 139: h = "VarNumeric" case 202: h = "VarWChar" case 130: h = "WChar" case else: h = "unknown (" & t & ")" end select debug_fieldtype = h end function ' Show all rows & columns of a recordset function debug_rs (rs) dim out, h, i, rows, cols rows = 0 cols = 0 if not rs.eof then cols = rs.fields.count h = h & " " & vbcrlf h = h & " Record" & vbcrlf for i = 0 to cols - 1 h = h & " " & server.htmlencode (rs (i).name) & "
(" & debug_fieldtype (rs (i).type) & ")" & vbcrlf next h = h & " " & vbcrlf while not rs.eof h = h & " " & vbcrlf h = h & " " & rows & "" & vbcrlf for i = 0 to rs.fields.count - 1 h = h & " " & debug_var (rs (i).value) & "" & vbcrlf next h = h & " " & vbcrlf rows = rows + 1 rs.movenext wend end if out = "

" & vbcrlf out = out & "" & vbcrlf out = out & " " & vbcrlf out = out & h out = out & "
Recordset: (" & rows & " records)
" & vbcrlf debug_RS = out end function ' Indent html code function prettyhtml (html) dim margin, maxtabs, tabwidth, blockpattern, lines, i dim rforward, rbackward, forward, backward, diff, junk margin = 0 maxtabs = 30 tabwidth = 3 blockpattern = "(head|table|tr|td|th|form|center|select|ul|ol|dl|map|blockquote|div|span|frameset|embed|pre|label)" ' Split input into individual lines lines = split (html, vbcrlf) for i = 0 to ubound (lines) lines (i) = trim (lines (i)) next set rforward = new regexp rforward.pattern = "<" & blockpattern rforward.ignorecase = true rforward.global = true set rbackward = new regexp rbackward.pattern = " 0 then margin = margin + diff if margin > maxtabs then margin = maxtabs end if end if next set rbackward = nothing set rforward = nothing prettyhtml = join (lines, vbcrlf) end function %>