home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
filutl
/
filscrub.arc
/
FILSCRUB.DOC
next >
Wrap
Text File
|
1987-02-18
|
9KB
|
463 lines
FILSCRUB
A table driven search and replace utility
Copyright 1987 by Gary Elfring
4N899 West Mary Drive
St. Charles, Illinois 60174
TABLE OF CONTENTS
INTRODUCTION .................................................. 1
SHAREWARE NOTICE .............................................. 2
OPERATION ..................................................... 3
TABLE FILES ................................................... 3
FUTURE IMPROVEMENTS ........................................... 5
FILSCRUB table driven search and replace utility
INTRODUCTION
FILSCRUB is a table driven search and replace utility. You make
up a table of text or characters to search for and what to
replace those characters with. FILSCRUB will look through your
input file for every occurrence of the first search entry. Each
time it is found it will be replaced with the first replace
entry. When the end of the input file is found FILSCRUB will
move on to the next search entry (if any) in your table.
FILSCRUB will work on ASCII or binary files. It uses the exact
file length and does not pay any attention to the control-Z (EOF)
marker. Search and replace strings can be any length up to 127
characters, and may be described in ASCII, decimal, or hex.
FILSCRUB does not affect your original input file in any way.
There is no limit on the length of the input file or the number
of search and replace operations to perform.
FILSCRUB can be used for many purposes. It can easily find all
special control characters in a text file and change them to
something else. Having problems with one word processor's out-
put? Clean it up with FILSCRUB.
FILSCRUB can also be used to translate information from one form
to another. FILSCRUB works sequentially through a file. It
performs one search and replace operation at a time, working
sequentially through your table. This gives FILSCRUB the ability
to literally translate one form of text to another.
1
FILSCRUB table driven search and replace utility
SHAREWARE
This program is provided on a "shareware" basis! Try the program
out. If you don't like it- erase it. If you do like it I hope you
will send in your contribution. I am requesting a shareware
contribution of $25.00. In addition, I would appreciate it if
you would send comments or bugs to my attention at:
Gary Elfring
4N899 West Mary Drive
St. Charles, Illinois, 60174
PLEASE mention the product name, (FILSCRUB), and where you got it
from. You will then receive: telephone support, and one free
update with improved documentation. Only registered users will
receive notices of improvements and the one free update!
Note that the next version of FILSCRUB will have a new option
that allows matches on ASCII text regardless of text case.
WARRANTY
NONE!! No warranty is provided to anyone who has not contributed
for this program. Gary Elfring specifically disclaims all other
warranties, expressed or implied, including but not limited to,
implied warranties of merchantability and fitness for a particu-
lar purpose with respect to defects in the disk or documentation,
and the program license granted herein. In no event shall Gary
Elfring be liable for any loss of profit or any other commercial
damage, including but not limited to special, incidental, conse-
quential, or other damages.
2
FILSCRUB table driven search and replace utility
OPERATION
To run FILSCRUB you need a text file to "scrub", a table of items
to search for along with the text to replace those items, and an
output file name. To run type:
filscrub table input output
Where: "table" is the name of a disk file containing at least one
search and one replace string, "input" is the name of your orig-
inal text file, and "output" is the name of the disk file the
results will be saved in. All disk file names may include drive
specifiers and path names.
No assumptions are made about the input or output files. They
may be ASCII or binary. The "table" file MUST be an ASCII file.
See the section below on table files for more details.
Once invoked, FILSCRUB will print a copyright notice and a ver-
sion number. The program will then begin working. The program
will read your text file once and thereafter work with temporary
copies of it until the final "scrubbed" version is complete.
While FILSCRUB is running it will be working with four different
files. Three of these are your "table", "input", and output
files. A fourth file, "scrub.wrk", will be created by FILSCRUB
for intermediate work. This file will be erased when FILSCRUB
completes it operation. Note that FILSCRUB requires TWICE as
much free disk space as your input file consumes. This is due to
the output and work files. Also note that if you search for a
large number of small strings and then replace them with much
longer strings, more disk space will be required!
TABLE FILES
The table driven approach of FILSCRUB makes it a powerful tool.
However, all table files MUST be written in ASCII! If your text
editor can not produce an ASCII file you must use another one
that does. (Much as I hate it you can use EDLINE that comes with
MS-DOS.)
How do you know if your text editor produces ASCII files? Try
using the MS-DOS TYPE command. If you can type out your files on
the screen, with no strange characters, your editor is using
straight ASCII.
Each table file consists of matching pairs of search and replace
strings. The text to search for (or replace with) can be written
in ASCII, decimal, or hex. All search and replace lines follow a
standard format. A line in your table file always begins with a
letter specifying whether the text to follow is ASCII, decimal,
3
FILSCRUB table driven search and replace utility
or hex. A second letter must follow specifying whether this is
the search or replace string. Finally, a space or tab must
separate you text from the initial two characters.
Some examples will probably help at this point. To search for
the word 'hello' and replace it with 'xxxxxxxx' you would enter:
as hello
ar xxxxxxxx
The "as" stands for ASCII search. The second line is the match-
ing replace string (ar = ASCII replace). Suppose you need to
search for two words? Try:
as "good bye"
ar good-bye
FILSCRUB will automatically detect beginning and ending quotes
and use all text in between as the search string.
There are a lot of different characters that can not be easily
described in ASCII. So FILSCRUB allows entry in either hex or
decimal. To look for a control-A and change it into the word
Control-A try:
hs 01
ar Control-A
If you like decimal it works the same way. To search for AAAA
and replace it with "4As" enter:
ds 65 65 65 65
ar 4As
The only limit on decimal, hex, and ASCII entries is that no line
in the table can be longer than 127 characters.
For more complicated work you can use multiple table entries. To
change all references from "hello" to "HELLO" and all references
from "HELLO" to "hello", (reverse the order of these words), try:
as hello
ar xxxxx
as HELLO
ar hello
as xxxxx
ar HELLO
When running with this table, FILSCRUB changes all references to
"hello" to "xxxxx" first. Then all references to "HELLO" are
changed to lower case. Finally, the original lower case hello
(now saved as "xxxxx") is changed into upper case.
4
FILSCRUB table driven search and replace utility
FUTURE IMPROVEMENTS
The next release of FILSCRUB will offer control of case when
searching for an ASCII string. (Assuming enough people support
this product as shareware.) This will allow you to optionally
match "HELLO" with "hello". The table for for this will be:
asc hello
ar xxxxxxxx
In this case all occurrences of the word "hello", regardless of
text case, will be replaced with "xxxxxxxx".
Other improvements may be made depending upon your suggestions.
Please send me your comments.
5