home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HomeWare 14
/
HOMEWARE14.bin
/
utils2
/
merge215.arj
/
MERGE.DOC
< prev
next >
Wrap
Text File
|
1994-04-20
|
18KB
|
348 lines
MERGEFILE v1.15 & v2.15 MERGE.DOC 4/20/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 THIS
PROGRAM MAY BE PLACED, THE PROGRAM SHOULD ALWAYS BE THOROUGHLY
TESTED WITH NONCRITICAL DATA BEFORE RELYING ON IT. YOUR USE
OF THIS SOFTWARE INDICATES THAT YOU HAVE READ AND AGREE TO
THESE AND ANY OTHER TERMS INCLUDED IN THIS COLLECTION 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 v1.15 4/20/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 will get if you enter MERGE
without any parameters. It should be able to merge files of any length
since it does all it's work on the disk (the minimum free space required
for the destination of the output file would be the size of the two input
files combined). If you need to merge more than two files, you can always
merge them 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.15 4/20/94 (Copyr. 1994 Hal Parks)
Everything that is true for v1.15 is true for v2.15, 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
before it occurs). MERGE defaults to case sensitive in ascending order
("H" will appear 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 identical keys, the line from FileName1 will merged). Lines can
have up to 255 characters. If the files to merge are not in your current
directory, the full path must be entered 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 halting 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: empty or blank line and
missing key or field. If /E is used, the merge will continue
without the reporting of any errors and all records, including
those with errors, will be written to the merge file. If you have
files to merge that may have a blank merge 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
both input files happen to have an empty line at the same time,
then 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 to /F9" = 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 order 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).
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 it would be kind of pointless to use /K, since
you would end up with the same list.
* 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.
The best way I can think of explaining MERGE's options is to use some
examples. Let's assume you have two files with 3 fields per record that
are sorted on all three fields (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 on all three
fields regardless of the order in priority, 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
corresponding to the error number shown below, but "PD"'s only pertain to
starting errors. The reason I'm mentioning them here is because "SW" can
report on errors during the actual merge and has the "/O" option, which
overwrites an existing file without prompting. The most likely place this
would be used is in a batch file. If you are batch processing, you could
use the command "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.
The output file could not be opened, most likely due
to an incorrect path (the directory does not exist).
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 : { reserved for future use }
6 : No filename specified.
You forgot to enter an input filename.
7 : { reserved for future use }
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 either have two or more identical "F" options, 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 "MERGEFILE" for point of merge error.
All the error messages above have something to do with
starting MERGE; 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 "MERGEFILE" 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 "MERGEFILE" for point of merge error.
This can occur if the primary 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, 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 for more information.
[Parameters] can be reached by calling 618-549-8448. Mail can also be
sent to any of the following addresses:
Hal Parks RIME: ->774 or PARAMETERS
404B W. Oak FIDO: 1:11/153
Carbondale, IL 62901 Internet: 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. Thanks.
Live long and prosper.