APPLICATION NOTE #173 HANDLING DATA FILES WITH INCONSISTENT RECORDS Rev. 01 This application note describes how to handle a mail merge when all the records in your data file do not contain the same number of lines. The default field separator is a single carriage return/line feed combination (); the default record separator is two carriage return/line feed combinations (). Normally, when you create a mail merge data file, you type each field of data on a separate line. For example: Betsy Ross separates fields 22 Pennant Park Philadelphia, PA 09223 separates records Liz Mountbatten 2 Castle Hill Queens, NY 20219 Emily Dickinson 1771 Poets Way Amherst, MA 01966 For mail merge to work properly, each record in the data file must have the same number of fields; and since they are default separators, you cannot include carriage returns as part of a field. A problem arises when the records in a data file contain an unequal number of lines. For example, some of the addresses in the following mailing list have two lines and others have three lines. Betsy Ross USA Flag Company 22 Pennant Park Philadelphia, PA 09223 Liz Mountbatten 2 Castle Hill Queens, NY 20219 Emily Dickinson Verse, Inc. 1776 Poets Way Amherst, MA 01966 The second address does not include a company name. If you try to process this file, XyWrite considers the city, state, and zip code to be field 4 in the first address, but field 3 in the second address. Your results will obviously be incorrect. If you try to compensate for the missing data by creating a blank field, your record will look like this: Liz Mountbatten 2 Castle Hill Queens, NY 20219 When you process this file, XyWrite interprets "Liz Mountbatten" as a record and "2 Castle Hill, Queens, NY 20219" as another record, because each is preceded by two carriage returns. The solution is to redefine the field separator to be something other than the default, so you can use a carriage return as part of the field. Then you can use the least number of fields common to all the records in your data file and include the carriage return to separate lines within a field. The previous mailing list example has three common fields: name, street, and city. We can handle the records that include a company name by entering a carriage return as part of the second field. 1. Call your printer file. For example: Type: F5ca 3epsonfx.prn 2. Use the FS printer file setting to change the default field separator to a slash (/).(We suggest you enter it immediately before the PT Tables in the printer file.) See Note #1. Type: FS 3. Store and load the printer file. Type: F5store Type: F5load 3epsonfx.prn 4. Create a data file, and enter your mailing list. Follow each field with a slash and each record with two carriage returns. When you encounter an address that has two lines, type a carriage return after the first line of the address. Now the data file entries would look like this: Betsy Ross/USA Flag Company 22 Pennant Park/Philadelphia, PA 09223 Liz Mountbatten/2 Castle Hill/Queens, NY 20219 Emily Dickinson/Verse, Inc. 1776 Poets Way/Amherst, MA 01966 Result: XyWrite processes the data file as having three fields, and treats the company name in the first and third records as part of the second field. If you use different mail merge separators for different data files or if you are on a network, you may want to create a special printer file that contains just field separators. Keep it with its data file and load it only when needed. Note #1 Changing Record Separators. This procedure only describes changing the field separator. If you want to change the record separator also, include the RS printer file setting on a line by itself in Step 2. For example to change the record separator to an asterisk: Type: F5RS<* Note #2 Carriage Return/Line Feed ASCII Characters. Although XyWrite carriage returns are represented on the screen as a single character (), they are actually stored internally in a set as carriage return and line feed. Line feeds are represented by an ASCII 10 character and carriage returns are represented by an ASCII 13 character. To define a carriage return/line feed combination as a separator, you must enter both ASCII characters: Type: Alt Shift 13 Type: Alt Shift 10 Note #3 Handling Existing Data Files. You can handle existing data file information as follows: 1. Use the FS and the RS settings to change the field and record separators to some character or string of characters that does not normally appear in your files (for example * and *, respectively). Type: FS<* Press: Alt Shift 13 Press: Alt Shift 10 Type: RS<* Press: Alt Shift 13 Press: Alt Shift 10 Press: Alt Shift 13 Press: Alt Shift 10 2. Change all the record separators in the file to another character or string of characters that does not normally appear in your files; change the field separator to the new default you established in Step 1; and change the record separator to the new default you established in Step 1. For example: Type: F5ci //@/ Type: F5ci //*/ Type: F5ci /@/*/ 3. Remove the field separator from any entry for which you want to include an extra line and enter a carriage return. For example: Change: Betsy Ross* USA Flag Company* 22 Pennant Park* Philadelphia, PA 09223* To: Betsy Ross* USA Flag Company 22 Pennant Park* Philadelphia, PA 09223*