GRGREF@BYUVM.BITNET (08/25/90)
Here's a useful little ARexx script that does the same thing as a zillion
other programs already do, but anyway...
All it does is take all CR characters out of a file. (If you want, it can
be easily modified to take any character or set of characters out of a file.)
This may come as a surprise...it's very fast! Try it out.
Have fun!
Bryan
/*
Compress - Compresses a file by removing certain characters - Bryan Ford
Usage: Compress <infile> <outfile>
Both files must be specified, and they must be different. (This could be
fixed, but I'm too lazy.) The <infile> is read in 60,000 bytes at a time,
all CR characters (or whatever the 'delchars' variable happens to be)
get removed, and it is written to the output file.
Although you would think a script doing something like this would be very
slow on large files, you might be very surprised! This script is very fast,
even on large files, mainly because it uses ARexx's COMPRESS() function
to remove the characters, which is a very fast routine (like most of ARexx).
Note that you can change the 'delchars' variable in the program to make the
program remove practically any character or even several different characters
at the same time.
*/
/* You could set this to anything, even several different types of characters */
delchars = '0d'x
/* ARexx strings have a 64K limit */
buffersize = 60000
parse arg infile outfile .
address command
/* Usage message */
if (infile = '?') | (infile = '') | (outfile = '') | (infile = outfile) then
do
i = 2
do forever
str = sourceline(i)
if str = '*/' then break
say str
i = i + 1
end
exit(0)
end
/* Open files */
if ~open(inhand,infile,'R') then
do
say "Can't open infile"
exit(10)
end
if ~open(outhand,outfile,'W') then
do
say "Can't open output"
exit(10)
end
/* Copy and compress */
do until length(instr) ~= buffersize
instr = readch(inhand,buffersize)
call writech(outhand,compress(instr,'0d'x))
end
/* Close files */
call close(inhand)
call close(outhand)
/* End of file */