home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Don Maslin Archive
/
maslin_archive.zip
/
AARDVARK_Tape_Backups
/
maslin_c_d_3oct95
/
ddrive
/
dw
/
xlate.doc
< prev
next >
Wrap
Text File
|
1991-05-24
|
6KB
|
140 lines
Sydex
___________________________________________________________
P.O. Box 5700
Eugene, OR 97405
(503) 683-6033
Xlate - A Simple Character Converter
January, 1991
Xlate and this document, Copyright 1991 by Sydex.
All Rights Reserved.
Synopsis
Xlate is a simple utility used to convert data on a character-
by-character basis. Xlate can--
1. Change every occurrence of one character to a different
character. (Character Translation)
2. Delete every occurrence of a character. (Filtering)
3. Insert a character after every occurrence of a given
character (Addition)
The transformations to be performed may be specified in one of
two ways:
1. In the DOS command line.
2. In a separate file.
Application
For most simple conversions, the DOS command line form will be
found to be the most useful. The general form of the Xlate com-
mand is:
XLATE IN=infile OUT=outfile FROM=string1 TO=string2
TABLE=tfile INSERT DELETE RAW
FROM=Infile specifies the file containing the data to be trans-
lated. If this specification is omitted, input is taken from the
standard input device, usually the keyboard.
TO=outfile specifies the file to receive the converted data. If
this specification is omitted, output is written to the standard
output device, usually the video display.
FROM=string1 and TO=string2 specify the translation that is to
take place. Each character in string1 is paired with its cor-
responding character in string2. Every time a character is read
from the input (IN) file, it is checked against the list of
characters in string1. If a character occurs in string1, the
character which occurs in the same position in string2 is sub-
stituted for it when the output (OUT) file is written.
Any printing character may occur in string1 and string2, with the
exception of the blank or space. If a non-printing character is
to be specified, it may be represented by its decimal value,
prefixed by a backslash (\). A backslash is represented by two
backslash characters. Thus,
\10 represents a line-feed, and
\32 represents a space.
If large numbers of translations are to be performed, it is most
convenient to specify them by means of a table contained in a
file. TABLE=tfile specifies this file. The "table" file consists
of any number of entries, one entry per line in one of the fol-
lowing forms:
value1=value2
value1-
value1+value2
Value1 and Value2 are character values and may be quoted with
double quotes (") or specified as a numeric quantity if preceded
with a backslash. For example,
A
"w"
\233
all are valid character specifiers.
The form value1=value2 specifies that every occurrence of value1
in the input file will be replaced by value2. The form value1-
specifies that every occurrence of value1 in the input file will
be deleted from the output file. The form value1+value2
specifies that every occurrence of value1 in the input file will
have value2 inserted immediately after it in the output file.
The keywords INSERT and DELETE have relevance only if a transla-
tion table file (TABLE) has not been specified. If INSERT is
specified, characters in the TO= string are not substituted for
those in the FROM= string, but rather inserted immediately after
each occurrence. DELETE specifies that every occurrence of a
character in the FROM= string will be deleted from the output
file.
RAW specifies how end-of-line characters are to be handled. Nor-
mally, a CR-LF pair in the input file is translated to a single
LF character on input, and translated back to CR-LF on output.
This allows treatment of the end-of-line as a single character,
rather than tow characters. If RAW is specified, this transla-
tion is disabled, and the end-of-line is given no special treat-
ment.
Here are some examples of XLATE commands:
XLATE IN=THISFILE OUT=THATFILE FROM=ABCDE TO=WVXYZ
translates THISFILE, converting every "A" to "W", "B" to "V", "C"
to "X" and so on. The translated output is written to THATFILE.
XLATE IN=FILE1 OUT=FILE2 FROM=\0 DELETE
removes all nulls (zero values) when copying FILE1 to FILE2.
XLATE IN=ALPHA OUT=BETA TABLE=MYTABLE
translates the file ALPHA, using the translations specified in
the file MYTABLE, and writes it to BETA.