A DeTab Utility
Using tabs in the source file instead of space characters makes code entry faster and prettier, a must for structured programmers.
BY MATTHEW J.W. RATCLIFF
Matthew Ratcliff is an Electrical Engineer at McDonnell Aircraft in St. Louis with the perfect job. He gets paid to program—in C and PL1—software for a high-tech imaging system used to evaluate ultrasonic test data taken on fighter aircraft parts. When he isn't programming at McDonnell or hacking at home, he's teaching his two young sons how to play video games and the art of computer-speak.
Many programmers soon realize, for several reasons, the advantages of using MicroEMACS or other relatively simple editors for code development. First, these text editors are fast, without all the frills of GEM's windows and menus, which clutter the screen and significantly slow down the user interface. The second advantage is the use of tabs, or programmable tabs.
Using tabs in the source file, instead of space characters, makes code entry faster and prettier, a must for structured programmers. Often as many as eight spaces are replaced by a single tab character. This improves the efficiency of file storage and can actually speed up compile times (since the compiler has to skip over only one "white space" tab character instead of eight space characters).
The use of tabs presents problems when it comes to printing your files, however. Most printers will recognize a tab character and move to the next eighth character position (i.e. 1, 9, 17, etc.). This can really spoil your "pretty listing" if your editor has tab stops at every four positions (the default used by Russ Wetmore's version of MicroEMACS), for example. Some printers are dumber in that when they see a tab they automatically spit out eight space characters, completely oblivious of the current print column (e.g. jump from position 6 to 14, instead of 9). I've run into these problems frequently, resulting in listings that are annoying and difficult to read.
One solution is to load the file into a word processor such as 1st Word or Word Writer. Word Writer uses the "typewriter standard" of five spaces for each tab stop, while 1st Word defaults to eight. If your editor doesn't use either of these settings, then you must remember to edit your tab stops before loading the source code.
The above nuisances can be easily eliminated with this utility, DETAB.TTP. When you double click on DeTab, a dialog box pops up, allowing you to enter the filename of your source code followed by a number separated by a space character. The number specifies tab size. If none is specified, a default of eight is assumed. If no filename is entered in the TTP entry dialog, then DeTab will remind you of the proper call format and prompt you for the filename and tab size.
DeTab will then generate a .DET (detabbed) file on the same drive, in the same directory. If PROG.C is detabbed, the output file will be PROG.DET. It will be a copy of the original, with all tabs expanded to space characters. You can then load the file into your word processor and do a printout, without all the annoying tab character problems.
The DeTab utility has saved me a lot of aggravation, and I hope it proves useful to you too.