April 3, 2000

By Karen Kenworthy

IN THIS ISSUE

Now I remember why God made me a computer programmer: It's sedentary, indoor work. I wasn't made for the great outdoors. Last week I attended a week-long self-defense class near the little town of Shawnee, Oklahoma. The class was terrific, chockfull of useful information. And we had perfect weather for the outdoor exercises. But when you expose your body to sunlight only a couple of times each year, it's easy to overdose. Add a year's allotment of running and jumping, crammed into five days, and you've got one exhausted little programmer.

Straightening Directory Printer

Still, I wasn't too tired to make some changes to our Winmag.com Directory Printer during my spare time. Old-timers may remember that this Power Tool started life a few years ago. Back then it could print a simple list of files and directories found on your hard drives, along with a little bit of information about each.

Thanks to several great suggestions, it's been enhanced several times. First, the program learned to write its information to a disk file. This allowed file and directory information to be copied into word-processing documents, imported into spreadsheets, and used in other ways. And just last week I added text to the top of printed reports, identifying the user who requested the report, and the computer where the report was prepared. But the most often-requested improvement had to wait, until now.

You might think Directory Printer's report was easy to design. After all, it just prints one line for each file. Each line includes a file's name, size, date created, and attributes (read-only, hidden, system, and archive). The result is an attractive, easy-to-read report in the familiar "columnar" format.

Or should be. The width of the columns needed to print most file information predictable. File creation dates vary, for example. But they all take up about the same amount of space on a printed page. The same is true for file sizes and attributes. This makes it easy to design a report.

Years ago, the lengths of file's names were predictable too. A name might be very short, perhaps containing just a single character. But the maximum size wasn't much larger -- just 11 characters (eight characters, followed by a period, then an optional three-character extension). Placing the names of files into a column of a report was easy.

But those days are long gone. Since the debut of Windows 95 back in um, err, 1995, filenames can contain as many 255 characters. Or they can still be as short as before. As a result, it's hard for a simple programmer, like me, to know how much space to set aside when printing a column of filenames.

Set aside too much space, and there will often be a wide span of blank paper before the end of a short filename, and the beginning of the next column of data. Allow too little space for the filename column, and longer names will overflow the space allowed, bumping into the data that follows. The result can be jagged, irregular columns such as these, which look best with a fixed-pitch font such as Courier:

About.frm   (A)  3/22/2000   1:44:14 AM      9,742 bytes
Dir.mdb     (AH) 3/22/2000   1:51:48 AM  1,499,904 bytes
LongFileNamesCauseProblems.vbw   (AHS)  3/25/2000  12:42:16 AM       225 bytes
DirPrn.exe  (A)  3/25/2000  12:40:12 AM     98,304 bytes

Old Programmer's Trick

The solution is an old programmer's trick -- rearrange the columns. Print all columns of predictable width first. At the end of the line, print the column (filename) whose width varies widely. The result is a form of alignment known as ragged-right. The left edge of each column forms a neat, straight vertical line. The space between columns can be controlled, keeping columns close enough to be scanned easily, but not so close they crowd one another. All large variations are confined to the far right side of the report, where they aren't as noticeable.

The result is a report that looks something like this:

3/22/2000 1:44:14 AM 9,742 A About.frm
3/22/2000 1:51:48 AM 1,499,904 AH Dir.mdb
3/25/2000 12:42:16 AM 225 AHS LongFileNamesAreNoProblem.vbw
3/25/2000 12:40:12 AM 98,304 A DirPrn.exe

The new Directory Printer uses one other trick you may not have seen before. To help your eye scan the report's lines, a little bit of extra space is added below every third line. I can't show that effect here. But the result guides your eye as you read across each line, keeping it from wandering off the line you intended to read.

I've got a few more tricks I want to teach the Directory Printer in the weeks ahead. But if you'd like to try this latest version (version 2.5), it's yours for free. If you'd like to add features of your own, help yourself to the program's Visual Basic source code too. They're both available for free on my Web site at https://www.karenware.com/powertools/ptdirprn.

In the meantime, if you see me limping along the road, or on the 'net, please don't touch my sunburned back. And pass the sunscreen. But whatever you do, don't forget to wave and say "Hi!"

YouTube button
Downloads Today: 3
More than 6000 downloads monthly
Received $184.68 this month* — Thanks!

License for Work

A license is required to use any or all of these tools for your work. You only need one per lifetime. If you make money with Karen's software, read her license agreement.

License for Work $25

Donations + Other Ways

Power Tools Newsletter

November 1st, 2023:

  • What is Karen's QR Code Talker?
  • What is a QR code?
  • What is a Code Talker?

List of All Issues since '99

24836 Verified Subscribers

Subscribe to receive new issues of the newsletter about Karen and her free Power Tools.

Click here to Subscribe

November Revenue* $184.68
*Licenses + Donations - PayPal Fees
Oct $211 Sep $166 Aug $173 Jul $225 Jun $324 May $200 Apr $700 Mar $273 Feb $405 Jan $56 (2023) Dec $349 Nov $546 Oct $253 Sep $232 Aug $189 Jul $379 Jun $188 May $484 Apr $212 Mar $519 Feb $89 Jan $462 (2022) Dec $1088 Nov $151 Oct $133 USD — Thanks again!