# Text Filter Utility

Topics
Usage | Compiling

Usage

The Text Filter utility is a console-based program used to filter any unwanted characters from a text file. This program can also be used to convert text files from a DOS format to a UNIX format or from a UNIX format to a DOS format. To use the utility, enter the name of the program followed by the name of the text file. NOTE: If you do not specify an output file name, the program will write to stdout.

    txfilter  myfile.txt (Write to console)

    txfilter myfile.txt newfile.txt (Write to myfile.txt file)

    txfilter myfile.txt > newfile.txt (Redirect to file under UNIX and DOS)

    txfilter myfile.txt >> newfile.txt (Append to file under UNIX and DOS)

You can pass one of several switches to the program from the command line. For a list of switches, execute the program with no arguments or with a "-?" argument: "txfilter" or "txfilter -?".

    ASCII Text file filter program 1031.101
    Usage: txfilter [switches] infile.txt outfile.txt (optional)
    Switches:  -?      = Display this help message.
               -d      = Output text file in DOS CR/LF format.
               -D      = Do not insert line feeds.
               -n      = No text filtering (defaults to filtered).
               -u      = Output text file in UNIX format (default).
               -P      = Output printable characters only (default).
               -A      = Output alphabetic characters only.
               -M      = Output alphanumeric characters only.
               -N      = Output numeric characters only.

The "-d" switch is used to output the text file in a DOS text file format. In DOS and Windows 95 there are two file types: a text file and a binary file. A DOS text file uses a CR/LF (Carriage-Return/Line-Feed) sequence to represent the end of a line in a text file and a Control-Z character to represent the end of a text file. In UNIX a single LF represents the end of a line and the end of a text file. If the "-d" option is not specified a UNIX format will be used.

The "-D" switch will not insert any line feeds in the output stream.

The "-n" switch is used to turn the filtering off so that the file can be viewed in its original state before it is filtered.

The "-u" switch is used to output the file in a UNIX text file format.

The "-P" switch is used to output all the printable characters in the text file. All control characters will be stripped from the text file and all carriage returns and line feeds will be inserted in their proper place.

The "-A" switch is used to output alphabetic characters only. All numbers and non-alphanumeric characters will be removed.

The "-M" switch is used to output alphanumeric characters only. All non-alphanumeric characters will be removed.

The "-N" switch is used to output numeric characters only. All alphabetic and non-alphanumeric characters will be removed.

Compiling

Console Base Utility Program

:
Four makefiles are provided in the "utils" directory to compile the source code on one of four different compilers.

    "msvc40.mak"  - Makefile for Microsoft visual C/C++ 4.2
    "djgpp.mak"   - Makefile for DJGPP gcc 2.7.2.1
    "gnu_gcc.mak" - Makefile for GNU g++ 2.7.2.1
    "hpux10.mak"  - Makefile for HPUX C++ A.10.24

Building the Executable:

To compile use the "make -f" option followed by the makefile name. To compile using MSVC use the "nmake -f" option. The resulting executable will be named after the name set by the PROJECT macro in the makefile. By default the program will be named "txfilter" under UNIX or "txfilter.exe" under Windows 95/DOS.

Installing:

Execute a "make -f (makefile name) install" to move the executable to the "bin" directory.

Removing the Object Files and the Executable:

To remove the object files and the executable use the "make -f" option followed by the makefile name, followed by "clean": make -f hpux10.mak clean

Under MSVC use the "nmake -f" option followed by the makefile name, followed by "clean": nmake -f msvc40.mak clean

End Of Document