home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
UTILS2
/
MERGE213.ZIP
/
MERGE.DOC
< prev
next >
Wrap
Text File
|
1994-02-20
|
17KB
|
335 lines
MergeFile v1.13 & v2.13 MERGE.DOC
NOTE: Enter COPY MERGE.DOC PRN to print this file. It is formatted
to print 6 pages with approximately 60 lines per page.
Files in MERGE213.ZIP: MERGE113.EXE (Public Domain MERGEFILE v1.13)
MERGE113.PAS (Turbo Pascal v5.5 source code)
MERGE.EXE (ShareWare MERGEFILE v2.13)
MERGE.DOC (this file)
HISTORY.DOC (notes on revisions)
REGISTER.DOC (registration/distribution)
FILE_ID.DIZ ("Description In Zip")
DESC.SDI (one line description)
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 NON-CRITICAL 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 DOCUMENTATION FILE.
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 the [Parameters]
BBS in Carbondale, IL for his patience and assistance in helping me gather
the information needed to assemble this collection. The [Parameters] can
be reached by calling 618-549-8448.
Public Domain v1.13 2/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.13 2/20/94
Everything that is true for v1.13 is true for v2.13, 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 must both be sorted lists. The merged list is
written to FileName3 if it is specified, otherwise to FileName1. 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,
then the line from FileName1 will merged). If the files to merge are not
in your current directory, you must enter the full path as part of the
filename. MERGE does not have to be in the same directory as the files
if it is on your 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, 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. Normally, MERGE will
prompt you if continuing will overwrite an existing file. This
will cause the merge to be performed without pausing, which could
be useful during batch processing (see ERROR MESSAGES below).
* "/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).
Lines up to 255 characters can be merged. 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 filenames and the first filename does not exist, then
FileName2 will be processed like a single filename and written to
FileName1. This accomplishes the same thing as a "merge" with one file
described above, except here you retain the original. This could also be
helpful if you are doing 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.
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.
2 : "INPUTFILE2" not found.
3 : "INPUTFILE1" not found.
: "INPUTFILE2" not found.
4 : Too many parameters on the command line.
MERGE "knows" how many parameters can be valid at one
time and the number on the command line is too many.
5 : Incorrect use of parameters and/or options.
Same as 4, but applies to options. Your total number of
parameters is ok, but somehow the mixture gave you more
options than is allowed.
6 : No filename specified.
You forgot to enter an input filename.
7 : There is a maximum of three filenames.
You have more than three filenames on the command line.
8 : "/ " is not a valid option.
The slash and character combination which will be
displayed is not a MERGE option.
* 9 : 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 nor
display the second line of the message above).
* 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 do use the shareware version and
find it useful, I think $5 is a fair contribution. If you send me a disk
in a self-addressed, stamped mailer, that 5 bucks will get you the latest
shareware version, its source code, along with anything else exciting (in
a "merge" program?) that comes along. If you don't send a disk but want
the latest edition, I am requesting an additional $5 for shipping and
handling. Please see REGISTER.DOC for more information.
Well, Happy Merging!
Hal Parks
404B W. Oak
Carbondale, IL 62901
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.