Saturday, May 19, 2007

Script Debugging Alternative in IE

Lately I have been experiencing problems with the Script debugger in Visual Studio 2005. The debugger is started by inserting a debugger statement in your code like so:



function doSomething()


{

for (i = 0; i < 10; i++)

{


debugger;

document.write(i)

}

}


This method of debugging is great because it allows you to debug just as you would with server side code. There are several blogs on the web that go into detail about how to do this. The problem I am having is that the Visual Studio script debugger randomly hangs for no apparent reason.

The other day I was forced to search for a better solution to solve a particular problem I had. One way that I have done this in the past is to use alert() statements, which is just ok at best, so I started asking around at work to see what others have done. One solution that a co-worker of mine (Ryan Garrett) had used was to use document.write()to output information to a new window like so:


var win;

if (!win)

{

win = window.open("","debug","width=400,height=260");

for (i = 0; i < 10; i++)

{

win.document.write(i);

}

}


This is a simple concept, and helped me tremendously in the problem I was solving. The code above instantiates a new window, iterates through a loop 10 times and displays the value of the index on each pass through the loop. The if(!win) check reuses the same window on each pass through the loop. This is important when you have several values you want to output, it prevent a new window from opening up for every value you display. Below is a screenshot of the popup this code creates.




Saturday, May 5, 2007

Gmail and Outlook 2007

I had some trouble setting up Gmail with Outlook 2007. It would receive mail just fine, but sending did not work. Something was up with the SMTP server settings. After enabling POP3 access in Gmail, which you are required to do, I did the following:

  • Click Tools à Account Settings to bring up the email accounts dialog window.
  • Click New.
  • Then it prompts for type of account (Exchange, POP3, etc.). POP3 is default so click Next.
  • The next screen prompts for name, email address and password. There is a check box at the bottom to manually configure server settings. By default this is unchecked so that Outlook will run the auto setup. Being a configuration kind of guy I decide to manually set it up to make sure all the settings are correct. So I check the option and click Next. (This grays out name, email address and password).
  • I continued with setup per Gmail's configuring your email client: Outlook 2003 (Microsoft had very similar documentation).

So now I'm done, right? Well, sort of. I can receive email, but cannot send. When I click Send/Receive Outlook shows its usual message about connecting to server. And it takes forever. Eventually it times out with a general error about not being able to send mail. In the more settings section in Outlook email account setup, on the advanced tab there is an Outgoing server (SMTP) box where you can enter a port to use. Google and Microsoft both say to use port 465, which did not work. I found a post somewhere on the web to use some other port number (forgot what it was), but that did not work either. I went through and tried every combination of all the other settings that could be causing this to not work correctly but to no avail. I opened new posts on a couple of different high traffic sites to see if anyone could provide some light on the situation. I got several responses with suggestions but nothing worked.

What finally did work for me was to let outlook run through the auto setup – it changed the SMTP port to 587. Now I can send and receive mail! So the lesson here is to try the idiot proof way first, if that doesn't work then manually configure.