w3Util Examples

Examples

Debugging ASP, another approach


This article describes how to debug asp-code without using theVisual Studio debugging support, which more often than not is quitea match to get up and running. Instead we will use two components called w3 NetDebug and w3 Utils, both from Dimac.


The general idea

w3 Utils should be installed on the webserver, it provides a lotof nice functions but for now we will focus on one of them, debugWrite. When calling debugWrite we send a network message which we pick up in a small clientprogram called w3 NetDebug. NetDebug is a commandline program which monitors netDebug messageson your local network.

How to do it

First of all, you will need to get and install Dimac w3 Utils on your webserver. You can find this component at www.dimac.net.

We create the netUtils object in a asp-page like this:

 

   

<%
   net = Server.CreateObject( "w3.netutils" )
%>


Meanwhile at another (or the same) computer in the local network, we start the w3 NetDebug client. It should look something like this:

Now then, add a debugWrite call to the asp page. The code looks like this:

   

<%
   Set net = Server.CreateObject ( "w3.netutils" )net.debugWrite "coding and stuff"
%>


Now, if you run the asp-page you will see the message appear instantly in the NetDebug client, like this:

Nice huh? Well, the following sample shows how you write variables to the netDebug client:

   

<%
   Set net = Server.CreateObject ( "w3.netutils" )
   net.debugWrite ( "New run ===========" )
   for i=0 to 4
      net.debugwrite( "i = " & i )
   if i=3 then
      net.debugwrite( "Here we go" )
   end if
      next
%>


Tips and tricks

Filtering

If you have alot of websites throwing netDebug messages and/or are a few developers, you might want to set some filters so that only you receive "your" messages. You accomplish this by (a) starting the client with a filter parameter (any word really) set and then (b) make sure all messages sent have with this word first in them.

For example, starting with netdebug mystuff would only show netDebug messages that contain the word mystuff. To make it effective you should then change all your debugwrite commands to look like this:

   

<%
   Set net = Server.CreateObject ( "w3.netutils" )
   net.debugWrite "mystuff: i = " & i
%>


Customize the window

As you might want the NetDebug window up all the time, it is advisable to customize the command prompt window. Do this by right- clicking the title bar and select properties. Change the font to a smaller one, and set the windows size to 15 or so. Remember to set the buffer size to something like 999. That way you can always scroll back and see old NetDebug messages.


Always on top...

Another thing you might want to do is to have the little NetDebug window always on top. Do this with the excellent little program called winPinIt! by tlai@kagi.com which "pins" windows to the top. You can get WinPinIt at http://www.geocities.com/SiliconValley/Network/5317/winpins.zip