home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 19
/
CD_ASCQ_19_010295.iso
/
vrac
/
m218_ch1.zip
/
MERGE.DOC
< prev
next >
Wrap
Text File
|
1994-09-17
|
20KB
|
363 lines
MERGEFILE v1.18 & v2.18 MERGE.DOC 9/17/94
NOTE: Enter COPY MERGE.DOC PRN to print this file. It is formatted
to print 6 pages with approximately 60 lines per page.
Please see PACKING.LST for a complete list of the files that should be
included with the MergeFile package. Refer to README.DOC for a brief
introduction to MergeFile and any late news.
DISCLAIMER OF WARRANTY
THIS SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO
THE RESULTS AND PERFORMANCE OF THIS SOFTWARE IS ASSUMED BY THE
USER. IN NO EVENT WILL THE AUTHOR OF THIS SOFTWARE, OR ANYONE
ELSE WHO HAS BEEN INVOLVED IN ITS CREATION, PRODUCTION, OR
DELIVERY, BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY DIRECT,
INDIRECT, CONSEQUENTIAL, OR INCIDENTAL DAMAGES ARISING FROM
THE USE OF OR INABILITY TO USE THIS PRODUCT. BECAUSE OF THE
VARIOUS HARDWARE AND SOFTWARE ENVIRONMENTS INTO WHICH THESE
PROGRAMS MAY BE PLACED, THEY SHOULD ALWAYS BE THOROUGHLY
TESTED WITH NONCRITICAL DATA BEFORE RELYING ON THEM. YOUR USE
OF THIS SOFTWARE INDICATES THAT YOU HAVE READ AND AGREED TO
THESE AND ANY OTHER TERMS INCLUDED IN THIS PACKAGE OF FILES.
After being confronted by the disclaimer above you're probably wondering
why you even thought about trying this program, but if I thought it would
hurt anything, I wouldn't be making it available. Unfortunately, our
litigious society has made disclaimers like this necessary. Please see
REGISTER.DOC for terms of distribution and registration.
ACKNOWLEDGMENT
I would like to sincerely thank Mr. Bob Pauls, sysop of [Parameters]
Information Services BBS in Carbondale, IL for his patience and assistance
in helping me gather the data needed to assemble this collection. Please
see the end of this document for information on contacting [Parameters],
which will always have the latest version of MergeFile available.
Public Domain version 1.18 9/17/94
There are plenty of routines around to sort lists, but one night I needed
a program to merge two lists and couldn't find any, so I wrote MERGEFILE.
There is nothing fancy about it, but it does what it's supposed to do, at
least it has for me. Everything that you need to know about how to use it
can be found on the "help" screen, which you get by entering MERGE without
any parameters. It should merge sorted ASCII text files of any size (word
processor files that contain formatting characters probably won't sort as
desired; lines need to be terminated by a carriage return--a line feed is
optional, but normally follows the carriage return) since it does all it's
work on the disk (the minimum free disk space required for the destination
of the output file would be the combined size of the two input files). If
you need to merge more than two files, they can always be merged two at a
time. I am releasing this version, along with its source code, to the
Public Domain, so you are welcome to do anything with it you want.
ShareWare version 2.18 9/17/94 (Copyright 1994 Hal Parks)
Everything that is true for v1.18 is true for v2.18, but the shareware
version has many additional features. The discussion that follows applies
to both versions, except for items that are marked with an asterisk (*),
which are only available as shareware. To make it easier on me (I don't
have to change a bunch of version numbers every time I release something
new), "PD" stands for the public domain version and "SW" the shareware.
Syntax: MERGE FileName1 [FileName2] [FileName3] [/C] [/D] [/K]
* [/H] * [/?] * [?] * [/E] * [/O] * [/F1../F9]
FileName1 and FileName2 are the input files and must both be sorted lists.
The merged list is written to FileName3 if it is entered (the input files
are unchanged), otherwise the last file name serves as both an input file
and the output file and is overwritten (you are prompted for an overwrite;
MERGE writes a temporary file, erases the original file when the the merge
is finished, and then renames the temporary file). MERGE defaults to case
sensitive in ascending order ("H" appears before "h"), using the entire
input line as the merge key, and discarding any duplicates in either or
both input files (if each file has the same key, the line from FileName1
will be merged). Lines can be up to 254 characters long (255 for "PD").
If the files to merge are not in the current directory, enter the complete
path with the file name. MERGE does not need to be in the same directory
as the files if it is on the path or invoked by specifying its directory.
"PD" has no error detection capability. If it encounters an empty line
(carriage return/line feed only) in one of the input files, it will stop
processing that file, but continue with the other file until the end (or
another empty line). It does not halt on a line of all blanks ("spaces").
"SW" will stop merging both files if it finds an error in either file and
display an error message (see ERROR MESSAGES below). Both versions retain
the merged file, but only with "SW" does it end at the point of the first
error (and leave the input/output file intact if a third file name was not
specified), which makes it easier to locate a mistake in the input file.
Options (enter without the quotes; they are not case sensitive, can
appear anywhere on the command line, and the order is not
important except for the "F" option as explained below):
"/C" = merge not case sensitive
"/D" = merge in descending order (the lists must also be sorted in
descending order)
"/K" = keep duplicates
* "/E" = disable halt on error. "SW" tries to detect 4 types of errors in
the input files and exits with an error message and errorlevel (see
ERROR MESSAGES below) if one is found: blank or empty line and
missing key or field. If /E is used, the merge continues without
reporting errors and all records, including those with errors, are
written to the merge file. If you are merging files that may have
a blank key field, e.g., lists of names to merge on the fields for
"LAST FIRST MI" where a middle initial is not required, you would
probably want to use /E. If an empty line happens to occur in both
input files at the same time, identical keys are being compared; if
you are not keeping duplicates, a side effect of entering /E would
be that only one of the empty lines is written to the merge file.
* "/O" = disable overwrite warning on existing files. This will cause the
merge to be performed without pausing for an overwrite prompt,
which could be useful during batch processing.
* "/H", "/?", "?" = all will access the "help" screen, as will entering
MERGE without any parameters
* "/F1../F9[RJn]" = merge field priority
* "/F?" can specify a different field to merge on, up to the first nine (one
or more "spaces" act as delimiters). You can enter multiple fields to key
on, in sequence of priority, e.g., /F3 /F1 /F5 will merge first on the
third field, then field one, followed by field five (the lists must also
be sorted in that order). The fields are "free form" in that they are not
specified by column numbers and a new field begins each time a space is
encountered (see Examples below). This can cause a problem for some data,
e.g., numerical, that should not be left justified (all leading spaces are
removed). If needed, add "RJn" to the end of the field number to right
justify the data in a field with width "n", where "n" is from 1 to 80.
If only one filename is entered, it will be written back on itself, e.g.,
to remove duplicates from a sorted list. All options available to either
version can be used, but using /K would be pointless, since you would get
the same list. You should not enter the same file name more than once
("SW" won't allow it; with three file names, if an input and the output
file have the same name, "PD" will probably crash with a run time error).
* If you enter two file names and the second does not exist, then FileName1
will be processed like a single file name and written to FileName2. This
accomplishes the same thing as the "merge" with one file described above,
except here you retain the original. This could also be helpful if you
are batch processing and one of the files may or may not exist depending
on the outcome of some other activity.
Examples
The best method I can think of to explain MERGE's options is by using some
examples. Let's assume you have two files with 3 fields per record that
are sorted on all three fields (the first field is the primary key, second
field the secondary key, etc.) in ascending order and you want to merge
them. As you can see, I'm not very good at coming up with original names,
but the reason I wrote the first program was to merge two sets of file
names (maybe a better example would have been to use people's names, like
LAST FIRST MI, but this by necessity is rather contrived):
FILE1 FILE2
----- -----
C:\BAT\0SIZE.BAT batchfile driveC A:\WORK.FIL anotherfile driveA
C:\BAT\0sIZE.BAT batchfile driveC C:\ANOTHER.FIL thisfile driveC
C:\BAT\0sIZE.BAT notsamefile driveC D:\LASTFILE whatfile driveD
if you enter: OUTFILE
------------- -------
MERGE file1 file2 outfile A:\WORK.FIL anotherfile driveA
C:\ANOTHER.FIL thisfile driveC
the files are merged on the entire C:\BAT\0SIZE.BAT batchfile driveC
line; since the merge is case C:\BAT\0sIZE.BAT batchfile driveC
sensitive, there are no duplicate C:\BAT\0sIZE.BAT notsamefile driveC
keys and every line is merged D:\LASTFILE whatfile driveD
MERGE file1 file2 outfile /c A:\WORK.FIL anotherfile driveA
C:\ANOTHER.FIL thisfile driveC
this is the same as above, except C:\BAT\0SIZE.BAT batchfile driveC
the merge is not case sensitive; C:\BAT\0sIZE.BAT notsamefile driveC
since the first two lines in file1 D:\LASTFILE whatfile driveD
now match, the second is discarded
* MERGE file1 file2 outfile /f1 A:\WORK.FIL anotherfile driveA
C:\ANOTHER.FIL thisfile driveC
now the merge is only on the first C:\BAT\0SIZE.BAT batchfile driveC
field and since the last two names C:\BAT\0sIZE.BAT batchfile driveC
in file1 are identical, only the D:\LASTFILE whatfile driveD
first of the two is kept
* MERGE file1 file2 outfile /f1 /c A:\WORK.FIL anotherfile driveA
C:\ANOTHER.FIL thisfile driveC
now all three keys in file1 are the C:\BAT\0SIZE.BAT batchfile driveC
same, so the last two are discarded D:\LASTFILE whatfile driveD
Coincidentally (hah), these files just happen to be sorted in ascending
order on all three fields regardless of the priority sequence, which means
I can use some more examples.
* MERGE file1 file2 outfile /f3 A:\WORK.FIL anotherfile driveA
C:\BAT\0SIZE.BAT batchfile driveC
since four names are identical in D:\LASTFILE whatfile driveD
the third field, only the first
in file1 will be retained (file1
always has precedence over file2)
* MERGE file1 file2 outfile /f3 /f1 A:\WORK.FIL anotherfile driveA
* MERGE file1 file2 outfile /f1 /f3 C:\ANOTHER.FIL thisfile driveC
C:\BAT\0SIZE.BAT batchfile driveC
for this example, both of these C:\BAT\0sIZE.BAT batchfile driveC
will produce the same output D:\LASTFILE whatfile driveD
* MERGE file1 file2 outfile /f3 /f2 A:\WORK.FIL anotherfile driveA
* MERGE file1 file2 outfile /f2 C:\BAT\0SIZE.BAT batchfile driveC
C:\BAT\0sIZE.BAT notsamefile driveC
you've probably got the idea by C:\ANOTHER.FIL thisfile driveC
now, but I have one more example D:\LASTFILE whatfile driveD
because it's easy
MERGE file1 /c /f1 C:\BAT\0SIZE.BAT batchfile driveC
If the merge (in this case, back on itself) is not case sensitive and on
the first field, all names in file1 are the same, and only the first name
will remain.
Incompatibilities
Please see INCOMPAT.DOC for incompatibilities. If you think you are
having one, or any other problem, please contact me through one of the
addresses given at the end of this document.
Error Messages
Both versions have several error messages and terminate with an exit code
(the numbers shown below correspond to the exit code for "SW"), but "PD"'s
only pertain to starting errors. "SW" can also report on errors during
the actual merge and has the "/O" option, which overwrites an existing
file without prompting. This would most likely be used in a batch file.
If you are batch processing, you could use "if errorlevel==" to test for
an error, and take action accordingly.
1 : "INPUTFILE1" not found.
or "INPUTFILE2" not found.
or both.
The same error number applies to all three
possibilities; the screen display will indicate which
file or files were not found.
* 2 : Error with output file "OUTPUTFILE".
Either the output file could not be opened before the
merge (most likely due to an incorrect path) or there
is an unknown file error with it after the merge.
3 : Cannot use fourth filename "ANYFILENAME".
You have more than three filenames on the command line.
4 : Incorrect use of parameters.
Somehow your combination of options and filenames
caused an error, e.g., too many total.
* 5 : Cannot use filename "ANYFILENAME" more than once.
You entered the same filename more than one time.
6 : No filename specified.
You forgot to enter an input filename.
* 7 : "/F?RJn" out of range; number must be from 1 to 80.
The right justification width "n" for the field number
shown is out of range.
8 : "/ " is not a valid option.
The slash and character combination which will be
displayed is not a MERGE option.
* 9 : "/F?" is an invalid or duplicate merge key.
You have two or more identical "F" options, entered
more than nine fields, or the character following the
"F" did not translate to a numeric value from 1 to 9.
* 10 : Terminated by user.
You ended the program by responding "N" to an
"overwrite" warning.
* 11 : Input file "INPUTFILE?" is empty.
The input file exists, so it was "found," but its size
is zero.
* 12 : Blank or empty line in input file "INPUTFILE?".
Check file "OUTPUTFILE" for point of merge error.
All the error messages above have something to do with
starting MERGE (except 2 which can also occur after the
merge is done); the rest check on the file(s) during a
merge. This error is displayed when one of the input
files has a line of only spaces or a completely empty
line (CR/LF only). To help you locate the error, MERGE
reports which input file caused the problem and retains
the output file so you can see at what point the error
occurred during the merge (if the error is at the very
beginning of one of the input files and the size of the
output file is zero, MERGE will not retain the file and
display a message that the file was deleted).
* 13 : Missing merge key in input file "INPUTFILE?".
Check file "OUTPUTFILE" for point of merge error.
MERGE can usually detect a missing primary merge key
field (the position where it should be is spaces) but
not all (detecting missing keys after the first is even
more difficult). Because the number of delimiters is
not fixed (you can have any amount of spaces between
fields) there are some combinations of empty fields and
primary merge keys, and any subsequent merge keys, that
will not be discovered.
* 14 : Blank or missing field in input file "INPUTFILE?".
Check file "OUTPUTFILE" for point of merge error.
This can occur if a merge key is not the first field,
but the first field is all spaces. It could also mean
that because a field or fields are missing, MERGE went
past the end of the input line trying to locate the
merge key field.
"PD" is free for the taking, but if you find the shareware version more to
your liking, I think $10 is a fair contribution. That 10 bucks will get
you a disk with the latest shareware version (less the unregistered
reminder), its source code, some utility programs, a technical assistance
phone number, and notification of anything else exciting (in a "merge"
program? well, updates, bug fixes, new products, etc.) that comes along.
Please see REGISTER.DOC and README.DOC for more information.
[Parameters] can be reached by calling 618-549-8448. Mail can also be
sent to any of the addresses shown below.
Write to: Hal Parks E-Mail: RIME ->774 or PARAMETERS
HAL SoftWare FIDO 1:11/153
404B W. Oak Internet
Carbondale, IL 62901 hal.parks@f153.n11.z1.fidonet.org
Happy Merging!
P.S. You don't have to be "registered" to get in touch. And if you find
anything wrong or have any suggestions on how to improve the program
or a feature you'd like to see, I'd be glad to hear from you.
Live long and prosper.