April 8, 2004
By Karen Kenworthy
IN THIS ISSUE
What a glorious day! Tiny green buds are covering the once bare branches surrounding the secluded Power Tools workshop. Last night at dusk, a recently expanded rabbit family crept from the shelter of the darkening woods to politely nibble their evening meal of new meadow grass. A wise turtle stole the last rays of the setting sun, just before sliding into his bed in the nearby creek.
Why did I think this world was old and tired? It's new-born, tender, resilient, and full of life!
It's too early for lightning bugs, June bugs, and butterflies. They'll be here soon enough though, once the days get a bit longer and warmer.
Yet one type of insect survives here year-round. I'll bet a few live near you too. Its technical name is "Softwarus Infectus". But most people just call this pest a "bug".
I battled one particularly stubborn example recently. If you're a computer programmer, this tale may remind you of some of your own big adventures. And if you've ever wanted to be a programmer ... well, this is a part of the job your Mother never told you about ...
My bug hunt began while the previous issue of this newsletter was still percolating through the wires of the 'net. New issues always trigger lots of return e-mail, and this issue was no exception. More than one reader wrote, thanking me for the new version of the Directory Printer program I'd just released. Seems a lot of folks liked the new features! Sweet notes like those always make my day.
But one message yanked me from my reveries. A reader urgently reported the new Directory Printer couldn't print at all! Instead of a stack of neatly formatted pages, each attempt produced an on-screen error message stating the "Printer could not be found".
Now, like any programmer, my first thought was "how did this poor, benighted reader lose his printer?" But in a matter of minutes, several identical reports filled my e-mail inbox. It didn't take this seasoned software professional long to realize the problem was a lot closer to home than I first suspected.
To pinpoint the locus of the failure (pretty fancy talk, eh?), I prepared a special version of the Directory Printer. It used an old programmer's trick called a "trace file". As the program ran, it recorded its program in a file, cleverly named "Trace.txt". Later, by studying this file, I can see how far the program ran before it failed.
Thanks to some very patient testers, it soon became clear what was happening. When asked to print, the Directory Printer told Windows to display its standard "Print" dialog. There a user can select the printer they want to use, specify the number of copies they need, and adjust other printer-related settings.
But for some reason, on some computers, this dialog never appeared. Instead Windows displayed the odd "Printer could not be found" error message.
Why? It took some detective work to unravel this mystery. But eventually I discovered this message could appear if "The [devices] section of the WIN.INI file did not contain an entry for the requested (default) printer".
Huh? WIN.INI? Many years ago, back when computers ran on steam power and bytes held just three bits apiece, Windows did store some configuration data in a file by that name. But WIN.INI has been obsolete for a long time. Today, if it exists at all, the file contains "dummy" entries to pacify old programs originally written for Windows 3.0 or 3.1. No modern program -- one written in the last 10 years or so -- uses the WIN.INI file.
Except Windows itself. :(
Yep. The WIN.INI files on my computers don't even have a [devices] section, let alone an entry for any of my printers. And the Directory Printer runs fine on all of them. And it runs fine on thousands of other computers too, most of which don't have the mystery WIN.INI entry.
But for some reason, the program failed on hundreds of other computers. I suspect there's a way to "work around" this problem Windows was having. If I spent more time trying different settings used when displaying the Printer dialog, perhaps I could make it appear under all circumstances, on all computers.
But this isn't the first time the Windows Printer dialog and I didn't see eye-to-eye. This pesky dialog has a nasty habit of changing a user's default printer without asking permission. It's difficult, and sometimes impossible, to fully customize the dialog, getting it to display exactly the options a program wants to make available. And it's surprisingly unreliable when performing seemingly simple tasks like asking a user how many copies they'd like.
Frankly, the standard dialog was more trouble than it's worth. So I did what I should have done long ago. I tossed the standard Windows Print dialog, and created my own.
The new dialog asks all the important questions. You can select any printer found in your computer's Printers and Faxes folder. It also lets you choose between Portrait and Landscape page orientations. Of course, you can specify the number of copies you'd like printed.
You can even tell the program the size of the paper you're using, and the bin or feed hopper where that paper resides. Another option allows you to specify the "quality" of the print. High resolution printing (more "dots" per inch) looks better, but can take longer to produce. Lower resolutions print faster, but may not appear as quite sharp or clear.
As an added bonus, as the printing capabilities of my Power Tools become more sophisticated, their new Printer dialog can grow up with them. And best of all, this dialog can always find your printer! :)
Less is More, Sometimes
I've often said the only program that's finished is one that no one uses. As long as a program is used, you can count on a steady stream of ideas, ways to make the program more efficient, flexible, powerful, or convenient.
If all goes well, these changes made to a program will be called "enhancements". If not, they may be called a nuisance (or worse). And, more often than you might think, they can end up being both.
We need look no further than the new Directory Printer for an example. As I'm sure you recall, this program can print lots of information about our folders, and the files stored within them.
Despite its name, the Directory Printer doesn't always print. If asked, it can save the information it collects in a disk file. Later, this file can be printed by a word processing program, archived, or e-mailed to a different location. The file can even be imported into a spreadsheet or database, analyzed, and used to prepare reports or statistics.
What does this file look like? It's an ordinary text file so a program like Windows' Notepad can display its contents. Take a look, and you'll quickly see each of its lines of text begin with one of four words: COMMENT, FILE, FOLDER or TOTAL.
Lines beginning with COMMENT reveal the date and time the file was created, and the user ID of the person who ordered the creation of the file. Other COMMENT lines disclose the computer, drive, and folders whose information is recorded within the rest of the file.
As you've probably guessed, FILE lines contain information about a single file. Depending on your selections, you may see a file's name, size or attributes. At your command, the file's date of creation, last access and last modification can appear too. Other possibilities include the file's MD5 and SHA1 Hash, and more.
I know you're way ahead of me now. Yes, lines beginning with FOLDER contain information about a particular folder. Here you'll see the folder's name and attributes. You'll also learn the number of files and sub-folders the folder contains, and total size of those files.
That leaves TOTAL lines. You've probably noticed they look a lot like FOLDER lines. In fact, like their near twin, they also contain information about a particular folder. But the numbers appearing on a TOTAL line are often much larger than the corresponding entries on a FOLDER line. That's because TOTAL lines reflect not only the files found in a particular folder, but also all files found in the sub-folders it contains.
When I added COMMENT lines to the file the Directory Printer creates, it seemed like a good idea. COMMENT lines can provide vital information, documenting the context of the other information in the file.
Placing FILE, FOLDER, or TOTAL at the beginning of the other lines seemed inspired too. They make clear the exact meanings of the other words and numbers on the line.
But these extras can also be a nuisance, cluttering the file with unwanted prattle. They may seem repetitious or distracting, wasting valuable disk space while confusing programs and humans that later view the file.
So, are these changes a blessing, or a curse? Do they qualify as enhancements? Or are they something less? Your e-mail made it very clear. The unequivocal answer is: Both.
That's why the newest version of the Directory Printer sports two additional checkboxes, visible when saving information to disk:
Omit COMMENT Lines - select this option and no COMMENT lines will appear in the file.
Omit FILE, FOLDER and TOTAL Line IDs - This option suppresses the words "FILE", "FOLDER" and "TOTAL" that normally appear the beginning of some lines.
So now, you're in the driver's seat. You alone control what's stored when the Directory Printer saves to disk. And if you ask me, the decision couldn't be in better hands. :)
I hope you'll give the latest Directory Printer a try. As always, the program is free for personal/home use. To download your copy, or learn more about its other features, just visit the program's home page at:
If you're a programmer, you can download a copy of program's Visual Basic source code too!
Better yet, get the latest version of every Power Tool -- including the new Directory Printer -- on a brand-new shiny CD. You'll also get three bonus Power Tools not available anywhere else. The source code of every Power Tool, the text of every issue of my newsletter, and some of my original Windows Magazine articles are included too. Owning the CD also grants you a special license to use all Power Tools at work.
Best of all, buying a CD is the easiest way to support the KarenWare.com web site, Karen's Power Tools, and this newsletter! To find out more, visit:
Until we meet again, I'll try to spend more time watching this amazing world around us. Hope you do to. And if you see me in the woods, or on the 'net, be sure to wave and say "Hi!"