Thursday, November 4, 2010

For those of us that are not super c/c++ gurus, like me, debugging an XP add-on can be quite challenging. Over the years I've tried numerous different ways to see into the inner workings of the code.

I first tried placing lots of InfoBox() calls to report on the code state. This worked to a point, but when I needed to see what way going on in a dynamic cursor, or anywhere that the user needed to interact with CC3, the InfoBox() tended to interfere. Plus building a string, that usually included numbers, just to output it to a message box seemed like a lot of work.

Then I added a bunch of code to write to a text file. This worked great but is was quite a bit of code and if I forgot to remove it, the end users got debug files that the shouldn't have. Plus you still needed to do all that code for creating your output string. And, if you wanted the file readable, you needed to include newlines, tabs etc.

Well, when we are first all taught c/c++ it is via the command line. The command printf/cout is king. We learn to output data to the console window in very simple ways. As we start to develop more and more complex applications, we could, for development purposes, interject tons of these little commands to see exactly what was happening.

Unfortunately, with the development of windowing software we no longer have the console window. Or do we?

If you are developing an XP add-on, (or any windows application for that matter) adding a console window is quite easy. Simply slip into your code two commands: AllocConsole & FreeConsole.