home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_300
/
344_02
/
xitab.txt
< prev
next >
Wrap
Text File
|
1989-06-06
|
3KB
|
94 lines
/* HEADER: (cat #);
FILENAME: XITAB.TXT;
SEE-ALSO: itab.c, xtab.c;
AUTHOR: Eric Horner;
*/
TEXT FILTERS FOR EXTRACTING AND REMOVING TAB CHARACTERS
-------------------------------------------------------
INTRODUCTION
XTAB.COM was originally designed because I kept forgetting to
set the default tab setting to 8 when I was using AEDIT! There is a
facility within AEDIT to replace tabs with spaces (macro <detab>), but
if you forget to use this before exiting AEDIT it's too late. XTAB will
replace tabs of a known width, so as to keep the format of the text
the same as it was in the original editor.
The next problem was that my files grew considerably in size
after "spacing out" the tabs, so I designed ITAB.COM to re-replace the
spaces with tab characters of required width.
The two programs can conveniently be used together, called by
a batch file, to change a file from one tab setting to another, as
shown in one of the examples below.
COMMAND LINE - XTAB.COM
xtab <input filename> <output filename> <tab width>
<input filename> is the name of the original file, which will remain
intact.
<output filename> is the name of the new file to be created with no
tab characters. NOTE: DO NOT USE THE SAME NAME AS THE INPUT FILE,
instead, produce a new file, check it, then delete the original file
and rename the new file.
<tab width> is a number (1 to 20) which is the tab width that the
original file was written under, which of course must be known, or can
be found by intelligent guesswork, by filtering at different width
settings until the file format looks good!
COMMAND LINE - ITAB.COM
itab <input filename> <output filename> <tab width>
<input filename> is the name of the original file, which will remain
intact.
<output filename> is the name of the new file to be created, with
spaces replaced by the optimum combination of spaces and tabs.
NOTE: DO NOT USE THE SAME NAME FOR BOTH FILES.
<tab width> is the setting desired for the new tab width (1 to 20),
which in most cases will probably be 8!
EXAMPLES
xtab short.c long.c 4
This would read file <short.c> and write it back out to file <long.c>,
after removing all tab characters, and replacing them with the correct
number of spaces to retain the original formatting, as produced with
tab width of 4.
Note that this is not the same as just replacing tab
characters with 4 spaces, as the number of spaces written each time
depends on where each tab character falls relative to the ORIGINAL tab
fields!
itab long.c shorter.c 8
This would read file <long.c> and write it back out to file <shorter.c>,
after replacing as many spaces as possible with tab characters, to give
a required tab field width of 8.
The following sequence, which could be part of a batch file, would
change the tab field width in the file <myfile.ext> from the original
setting of 4 to a new setting of 7 (???)
xtab myfile.ext temp1.ext 4
itab temp1.ext temp2.ext 7
del myfile.ext
del temp1.ext
rename temp2.ext myfile.ext
Of course if a batch file were being used here, the filename
<myfile.ext> would be passed as a replaceable parameter, and checks
would have to be done to verify that each new file had been written,
before proceeding!
END OF XITAB.TXT ERIC HORNER, 6/6/89