
MERGEF.HLP         SPECIAL MERGE SYSTEM INSTRUCTION AND
			     DISCRIPTION 

*******************************************************************************

WRITTEN BY:  RONALD HOEKSEMA
             PERSONNEL DEPARTMENT, THE FIRST NATIONAL BANK OF CHICAGO
             1 FIRST NATIONAL PLAZA, 22ND FLOOR
             CHICAGO, ILLINOIS  60670

DATE:        SEPTEMBER 17, 1982


*******************************************************************************

	Neither First Chicago Corporation, the First National Bank of Chicago,
nor any of its employees makes any warranty, either expressed or implied,
assumes any legal liability, nor any responsibility for the accuracy,
completeness or usefulness of any information, product or process disclosed.
Neither does First Chicago Corporation, the First National Bank of Chicago, nor
any of its employees represent that use of this material would not infringe
privately owned rights.

*******************************************************************************

INTRODUCTION
	This is a brief description of a C program that merges two persorted
FSA files together according to their respective sort key. The program
,MERGEF.C, has many comment statments and should be somewhat self 
documented.

CONCEPT
	Occasionally the need arrises to merge two FSA files together.
This can be done using MERGEF.C providing that each file has a common "key" 
variable and that both files are sorted (ascending order) by this key
variable.
	MERGEF compares the key feilds character-by character in each file.
If a match is found, file #2 is concatenated to the end of file #1.
If no match is found, blanks will be added to the end of file #1 so that the 
resulting line is the same length as when a match is found.
	The resulting file (output) will have the same number of lines as
file #1, and the number of characters in each line will be the sum of the
number of characters in file #1 and file #2.

RUNNING THE PROGRAM
	MERGEF can be run from either a command file or by itself. In either
case the program prompts for 8 different parameters. These parameters will 
each be described.

	To start the program enter : R MERGEF

	MERGRF will respond with 'Argv.'. At this point a "return" should be entered.
This would be a blank line for a command file. MERGEF then responds with a short 
message after which it will start with the first of the 8 prompts. They
will be described in order of appearance.

	ENTER : NAME of input file # 1 :
	This is the complete file name for the primary (file#1) file that is
to be merged by MERGE.

	ENTER : file SIZE (characters per record) :
This requests the line character count. The number of characters, starting
with the first character, that will be written to the output file. This is
frequently but not necessarily the number of characters read from each line in
the file. MERGRF reads each line until it finds a linefeed character, therefore,
if the actual line is longer than the number of characters specified the output
file will contain a shortened copy of the input file. The opposite can also
happen. If the number of characters specified is greater than the actual
number found, the output file could contain the linefeed and carriage control 
characters from the input file as well as some garbage that was in the buffers.

	ENTER : KEY starting position :
	This is the starting character position for the sort key field in
file #1. All position counts used in MERGEF start with '1' and not '0'.

	ENTER : key LENGTH :
	This is the number of characters that are to be used as the key field.

	ENTER : NAME of input file #2 :
	This is the complete name for the second (table) input file.

	ENTER : file SIZE :
	This requests the number of characters (starting with the first character
in the line) from file #2 that are to be concatenated to file #1.

	ENTER : KEY starting position :
	This is the character starting position for the key field in file #2.

	ENTER : NAME of output file file :
	This is the complete file name for the output file.

PROGRAM EXECUTION AND MESSAGES
	Some FSA files have a linefeed character as the very first 
character in the file. MERGEF looks for and ignores any nonprintable
character that is found at the beginning of the file. MERGEF will print a 
message if it removes any such character. The messages are :

		file 1.. delete char : nn
		file 2.. delete char : nn

where "nn" is the decimal representation of the character removed.

	If any line in file #1 is not matched to a line in file #2 the following
message plus the complete line is printed.
	
		NO MATCH..FILE #1..LINE # nn >>

where "nn" is the line count within file #1 where the line is located.

	When MERGEF is finished it prints a summary of what was done.
Line counts for each file is given. The line length for each file is also printed.
The count of non-matches for both input files are given.
	MERGEF terminates when both input files have been completely read and
no additional matching is possible. MERGEF will define a file as reaching EOR
when the function (fgetc) that reads each file returns a NULL or when a non-printable
character is found in position 1 of any line except the
very first lines in the file.
