Debugging Variables Made Easy

Debugging Variables Made Easy

At one time or another, all ASP progrmmers have used RESPONSE.WRITE to write out a variable on the screen, ensuring that the variable is passing correctly or has the correct value. Then, when the page goes live, you have to go back and comment out or delete all those RESPONSE.WRITEs.
I have found a way to display your variables with only one line change.
At the top of your ASP page add the following line:


Then, anywhere you need to display a variable, add.

 If DEBUG_MODE then  RESPONSE.WRITE "MyVar = " & MyVar & "
" ' add more if neededEnd If

The Above code says If DEBUG_MODE is TRUE then display “MyVar” (change MYVAR to the name of your variable). Whenever you want to show your variables, go back to the top of the page and set DEBUG_MODE to True:


Save the page and reload it in the browser. Your variables will be displayed. Once you’re done debugging, set DEBUG_MODE back to False and be done with it.
Hope this tip helps someone. Please give feedback to [email protected].


Share the Post: