MERGE.DOC (v 2.0, 20 Feb 87) Gene Clark INTRODUCTION 1. This brief (and tongue-in-cheek) instruction will lead you through a few uses of MailMerge which is one of the companion programs of WordStar. Both are copyrighted by MicroPro Inter national Corporation. 2. In the examples that follow, we'll explore the easy way to address envelopes as well as print some "personalized" form letters. 3. After you have read this text you will work with some files that are already on the disk. When you see the filenames I have chosen, you may not agree that I try to use logical file names. Whether you agree or not -- I try to give my working files names that somehow apply to their usage. I do not normally add a file "type" (e. g., ENV.MRG) because the .typ becomes .bak whenever the file is edited and saved and more importantly, four extra (and unnecessary) key strokes are needed to bring the file into use. Here are the files you'll be using: MERGE.DOC You have already used this one to print the document you are reading. ENVADDR means literally "ENVelope ADDRess" and will be used to address envelopes. When you prepare your own ENVADDR file, you will use your own return address rather than the fictitious one used in the exercise. ADDFILE means ADDress FILE. The file will contain names, addresses, and other data pertinent to the mailing list. LTRMERGE means LeTteR that will be MERGEd. In actual use, I generally use a filename that follows my normal "naming" procedure. ENV is the file you will use to address the ENVelopes for the letters you print using LTRMERGE. ENVADDR - Background 1. One of MailMerge's print commands is ".AV" which means (literally) "Ask for Variables at printing time." In this in stance we'll use .AV to ask the operator (you, that is) the name and address to place on the envelope. Your return address will be in the file, so we won't need to enter that. 2. Your ENVADDR file looks like this: .op .mt 0 .pf off .po 3 .av name .av street .av city Mabel Smith 12 34th Street Somewhere, Somestate 98765 &name& &street& &city& .pa_________________________________________________________________ 3. The example file (ENVADDR) uses the default "Variable Name Symbol" shown on page 5-5, Appendix 5, of your WordStar Manual. I'm referring to the ampersand (&) that precedes and follows each variable. If you'd rather use some other symbol you can change by "reinstalling" WordStar. I chose to stay with the default (&) because the examples in MicroPro's manuals use it. (I'm not smart enough to translate or transpose symbols when I'm trying to follow a text to learn a system.) If you decide to use a different symbol, I suggest that you defer changing until you are familiar with MailMerge and its characteristics and idiosyn crasies. 4. Let's go over the "dot commands" used with ENVADDR: .op omit automatic page numbering .mt 0 lets us start printing the return address at whatever point the envelope is positioned .pf off turns off "print time line forming" which would cause automatic "word wrap" in case of a long address that extended beyond column 65 .po 3 reduces "page offset" to 3 columns so the return address will be near the left margin .av name, street, city identifies the variables you will be asked for when you start to print the envelope 5. You ought to be familiar with your name and address, so we'll not have to discuss that. 6. Next we find &name& &street& &city& which translates to (for example): John Doe 123 4th Street Possum Trot, Oregon 99999 Note that STREET is not literally the street nor is CITY limited to just the city. The terms NAME, STREET, and CITY are terms that you give the word processor so that it will query you (to fill in the blanks) and then position the information (your answer to the query) in the right place. It wouldn't make any sense to do so, but you could use (in lieu of NAME, STREET, and CITY) DOG, CAT, and CANARY -- or ONE, TWO, and THREE -- as long as you use the same terms in the .AV lines as you do with the ampersands. 7. Close the file with .PA - the normal "page break." 8. The file ENVADDR is called a master document and is, in effect, a blank form that is partially filled out and that will be completed at the time of printing. 9. I have from one to three versions of ENVADDR on each of my disks used for correspondence. You might want to use this version for plain No. 10 envelopes and another version for the smaller envelopes used for notes. (Be sure to use a different filename for other versions.) ENVADDR - Printing 1. Insert a disk containing WordStar and MailMerge in Drive A and the disk containing ENVADDR in Drive B. 2. Turn on the printer. Insert an envelope so that the top is about one line above the print wheel. 3. Call up WordStar and log onto Drive B. 4. Enter "M" (for MailMerge), press RETURN. 5. See: Name of File to MailMerge? 6. Enter ENVADDR and press ESCAPE. NOTE: Step 7 will not start until printer is all ready to go! 7. See: NAME? Enter John Doe, press RETURN 8. See: STREET? Enter 123 4th Street, press RETURN 9. See: CITY? Enter Lost Wages, NV 12345, press RETURN ...and STAND CLEAR while envelope is printed! ADDFILE 1. ADDFILE is a data file that contains the information that will be merged into a "master document" by MailMerge. Data files are created and/or edited in the non-document mode; that is, use "N" rather than "D" when opening or editing the file. 2. If you want to run a proof sheet of a data file, you'd better put the paper in the printer "the long way" because indi vidual "records" (one line of the file) often exceed a normal page width. Also, you may need to turn Print Time Line Forming "off" when printing. 3. Your ADDFILE looks like this: 1,Charles Applegate,Dog Catcher,12345 W. North, "Chicago,IL 11111",Charlie,Chicago 2,E. L. Baker,,2345 S. East St.,"Amarillo,TX 22222",Ed,Amarillo 3,Mrs. Mary Caruso,Secretary,345 N. West Drive,"Barrington, IL 33333",Mary,Barrington 4,"Harold L. Doggett,M.D.",Health Officer,Box 177,"Windsor, CT 44444",Hal,Windsor 4. Note that each record (a single line of the file) consists of a series of data fields all separated by commas. (The comma is the default "data field separator" shown on page 5-5, Appendix 5, WordStar manual.) Note also that a data field that contains a comma is surrounded by quotation marks. 5. Sometimes a data field must be left blank. Example: Three of the records include a TITLE. We have to show a field for TITLE even if the individual has none, so we create a "dummy" field with a second comma. (See Record No. 2, following the name "E. L. Baker.") A space between the two commas of a dummy field is optional. 6. Each RECORD in a data file must have the same number of fields. (MailMerge cannot read. All it can do is count - it counts data fields.) If one record has fewer fields than the next it throws the count "off" and MailMerge blissfully prints wrong data in the blanks. 7. In the master documents we'll tell MailMerge how many data fields are in each record, and we'll assign arbitrary (or logical) names to each field. LTRMERGE - Background 1. LTRMERGE is a master document and, like other master documents, is a blank form that will be completed by MailMerge using ADDFILE to fill in the blanks. 2. Now for a look at LTRMERGE: .op .cw 11 .df ADDFILE .rv N, NAME1, TITLE, ADDRESS1, ADDRESS2, NAME2, LOCALE Mabel Smith 12 34th St. NW Somewhere, Somestate 98765 24 June 1987 &NAME1& &TITLE/O& &ADDRESS1& &ADDRESS2& Dear &NAME2&: This is just a short example of a form letter that will be sent to a number of people. With any luck at all, each of them will think that his/hers is an original. By the way, how are things in &LOCALE&? Sincerely, Mabel .pa_________________________________________________________________ 3. How about those crazy dot commands? .op If you don't turn off the automatic page numbering, each page will be sequentially numbered. For example, the 2nd page of the 12th 2-page letter would be numbered "24." .cw 11 Use whatever spacing is appropriate. .df addfile identifies the data file that will be used to fill in the blanks in the master document .rv n, name1,title,address1,address2,name2,locale identifies the fields in each record. (Read Variables) Let's compare the .RV line with the information in the data file (ADDFILE). n, name1 , title , address1 , address2 ,name2,locale 1,Chas. Apple,Catcher,23 W. North,"Reno, NV 11111",Chuck,Reno I use "n" for the number of the record only because the MailMerge manual showed it. The record number is not actually necessary, but it helps me a little. The important thing to remember is that YOU MUST GIVE A GENERIC NAME TO EACH FIELD WITHIN THE RECORD. 4. You're familiar with the use of the ampersand (&) to identify generic names to be filled in from the data file. No tice, though, the second generic here (TITLE) is followed by a "slash Capital O." That's our way of talking to MailMerge. Decoded, it means: "Hey, MailMerge! If there is no TITLE shown for someone, don't worry. Just be sure you don't leave a blank space!" Without the "/O" the second letter would have the addressee shown as: E. L. Baker 2345 S. East St. Amarillo, TX 22222 LTRMERGE - Printing 1. Insert your Wordstar/MailMerge disk in Drive A and your new (MERGE) disk in Drive B. 2. Call up WordStar and log on to Drive B. 3. Set the printer for the type paper you'll be using -- either continuous form paper or individual sheets. 4. Enter "M" (for MailMerge) and press RETURN. 5. See: Name of File to MailMerge? 6. Enter LTRMERGE and press ESCAPE. 7. Stand clear while all four letters are being printed -- unless you are using individual sheets and have to insert the new paper for letter 2, 3, and 4. NOTE: Both the "P" (Print) and "M" (MailMerge) commands can be actuated by either RETURN or ESCAPE. The latter eliminates the need to answer all those silly questions before we get started printing. ANOTHER NOTE: If you screw up and (for example) need to reprint letters 2, 3, and 4, MailMerge thinks the 2nd letter is page 2, the third is page 3, etc. (That's because these are one-page letters.) You can use the RETURN rather than ESCAPE, answer the 2nd question with a "2" and then press ESCAPE and away we go! STILL ANOTHER NOTE: MailMerge has another option that you might find useful in normal printing: multiple copies. Suppose you need four original copies of a particular file. Instead of using "P" use "M" and RETURN for printing. When asked "Number of Copies?" enter "4" and press ESCAPE. ENV - Background 1. ENV is a master document and will be used to print envelopes for the four letters you just now printed using LTRMERGE. 2. The file looks like this: .MT 0 .OP .PF OFF .PO 2 .DF ADDFILE .RV N,NAME1,TITLE,ADDRESS1,ADDRESS2,NAME2,LOCALE Mable Smith 12 34th Street Somewhere, Somestate 98765 &NAME1& &TITLE/O& &ADDRESS1& &ADDRESS2& .PA_________________________________________________________________ 3. Do the dot commands look familiar? I haven't used a character width (.cw) command so the default will apply. If you are using a very dainty print you might want to close it up a bit by using .cw 10 or even .cw 9. 4. Note that .RV identifies all the data fields even though we won't use all of them in addressing the envelopes. Remember: MailMerge only counts what it reads; it doesn't understand what it reads. ENV - Printing 1. Print the envelopes exactly as you did the letters EXCEPT set the printer for individual sheets! If you don't, the second address will be printed on the platen before you can get the damn thing stopped. 2. Again, MailMerge will consider each envelope to be a separate page. That's handy when you have to go back and do one (or more) over again. REVIEW 1. MailMerge is a very useful supplement to WordStar. It is just as ornery as WordStar in that it'll do what you tell it, even if you tell it wrong! > Check and re-check your data files. > Check and re-check your master documents. 2. Now that you've seen what Mailmerge can do (We've just scratched the surface!) and you've lost some of your fear hesitancy, it's probably safe now for you to read the manual. 3. Make haste slowly! CONDITIONAL PRINTING 1. In our example "LTRMERGE" we sent the same letter to several people. But suppose we want to write a 3-paragraph letter and send the first two paragraphs to some people and send paragraphs 1 and 3 to the others. Fortunately, MailMerge has some more dot commands that will make the task possible: .IF means "IF true. . ." .EX means "EXcept when true. . ." (or simply, if false) .EF means "Skip to here when directed by .IF or .EX." 2. It may be simpler to add some "conditional" paragraphs to our LTRMERGE example. We'll give our new letter a new name, though. Let's call it LTRMERG2. .op .cw 11 .df ADDFILE .rv N, NAME1, TITLE, ADDRESS1, ADDRESS2, NAME2, LOCALE Mabel Smith 12 34th St. NW Somewhere, Somestate 98765 24 June 1987 &NAME1& &TITLE/O& &ADDRESS1& &ADDRESS2& Dear &NAME2&: This is just a short example of a form letter that will be sent to a number of people. With any luck at all, each of them will think that his/hers is an original. By the way, how are things in &LOCALE&? .EX &NAME2& = "Mary" GOTO Will you arrange for facilities for our Spring meeting? A small conference room should suffice. A restaurant should be at or near the selected site. .EF .IF &NAME2& = "Mary" GOTO I've asked Mary to arrange for facilities (with a restaurant nearby) for our Spring meeting. I'll let you know the details when I hear from her. You'll be able to attend, won't you, &NAME2&? .EF Sincerely, Let's analyze the .EX and .IF commands. .EX &NAME2& = "Mary" GOTO (See Note 1) Will you arrange for facilities for our Spring meeting? A small conference room should suffice. A restaurant should be at or near the selected site. .EF .IF &NAME2& = "Mary" GOTO (See Note 2) I've asked Mary to arrange for facilities (with a restaurant nearby) for our Spring meeting. I'll let you know the details when I hear from her. You'll be able to attend, won't you, &NAME2&? .EF (See Note 3) Sincerely, Notes: 1. Notice that "Mary" uses upper and lower case letters, just as it appears in ADDFILE. "EXcept_ where_&NAME2&_is_"Mary"_jump_to_the_next_'.EF.'" 2. "IF_&NAME2&_is_"Mary"_jump_to_the_next_'.EF.'" 3. This ".EF tells MailMerge to start reading the file again, and since there is no exception (.IF or .EX) to start printing. Print LTRMERG2 using MailMerge. Use the "return" sequence to start the printing if you want to print only pages 2 and 3, for example. MailMerge also allows us to use "Complex Conditional Commands." (The operative word here is "complex.") .IF &NAME2& = "Mary" .OR. &NAME2& = "Charlie" GOTO -- schedules a jump if the letter is addressed either to Mary or Charlie. Sometimes we may want to use a "Comparison" character. .IF &N& >= "2" GOTO -- If "N" is greater than or equal to "2", then jump to .EF. We can even combine "Complex" and "Comparison" like this: .IF &N& > "1" .AND. &N& < "4" GOTO -- (If "N" is greater than "1" and also is less than "4" then . . .) These "comparison" characters would be useful if, for example, we had established a separate DATA FIELD for Zip Codes. Now that you've seen it work you may want to browse through Section 5. of the MailMerge Manual. MENU Another use for MailMerge is one described by Joseph Comanda in an article in the March 1987 issue of PROFILES. (You'll never find this example in the MailMerge manual!) The example that follows deals with addressing envelopes, but the "program" can be custom tailored to do what you want it to do. For my use, I've made it to print address labels for several people with whom I correspond most often. Of course you can make it do whatever you want - or need- it to do. And since it is "menu driven" you can make it do several things. Here is what your "menu" looks like: PRINT SELECTION MENU =============================================== 1. AKINS 4. EZ-LABEL 7. 2. BULLOCK 5. 8. 3. COLLINS 6. 9. 10. quit =============================================== Enter the number of your selection: Notice that the menu tells you how to choose the particular product that you desire. The program will also tell you if you've made a mistake and what to do to correct it! Let's "run" it once, just to get the feel of what it will do for us. But first, a couple of cautions: > It will be easier to use (and will work faster) if you turn off the file display first. (At the Opening Menu enter F.) > WordStar should not be set to pause between page breaks. (I'm talking about WordStar, not the printer. I'll tell you how to be sure it's set right in a minute.) Running MENU 1. Enter: F. 2. Enter: M. See: Name of file to MailMerge? 3. Enter: MENU * or a.* See: Disk File output (Y/N)? b.* See: Start at Page number.... c.* See: Stop after Page number... d.* See: Use Form Feeds? (Y/N) 4. Enter: Y * This sequence is necessary if WordStar's Form Feed Toggle (option "O" in the Menu of Word Star Features in the WordStar Installation procedure) is set to "off." If the toggle is set to "on," merely enter at Step 3 rather than using the sequence. I've set up this version of MENU for ten selections, only five of which are used. The last (Number 10) is the "escape" sequence to get you back to WordStar. There are practical limits to the number of options or selections: One constraint is the size of your screen - the number of lines and the number of columns. The other is the number of the files that you an put on your disk. (You will have to establish a separate file for each of the selections shown plus one for MENU.) First, let's print an envelope for each of those people we have listed. (Use scrap paper, not new envelopes!) 1. Enter "1" (I hope you have the paper in the printer. 2. Watch message on screen - then the menu will come back. 3. Enter "15" 4. See the message on the screen. 5. Enter "4" to print a string of 5 labels. 6. Enter "10" to quit and return to WordStar. 7. Enter "F to get the file display back. I am going to show you what the file "MENU" looks like so that you can change it to fit your needs if it appeals to you. (Notes)* .DM PRINT SELECTION MENU a .DM =============================================== .DM 1. AKINS 4. EZ-LABEL 7. .DM 2. BULLOCK 5. 8. .DM 3. COLLINS 6. 9. .DM 10. quit .DM =============================================== .AV" Enter the number of your selection: ",CHOICE,2 b .EX &CHOICE& > "0" .AND. &CHOICE& < "11" GOTO WRONG c .IF &CHOICE& = "10" GOTO END d .CS e .DM N O W P R I N T I N G .FI FILE.&CHOICE& f .IF &CHOICE& > "0" .AND. &CHOICE& < "10" GOTO REPEAT g .EF WRONG .CS .AV" INVALID OPTION! Hit RETURN and try again.",RETURN .EF REPEAT .CS .FI MENU h .EF END *Notes: a. .DM means "Display Message on screen." b. .AV means "Ask for Variables," just as it did in our ENVADDR file. The variable being asked for is "choice," shown near the right edge of the line. The figure "2" allows us to enter up to 2 digits. The quotation marks make the enclosed words respond as though we had used .DM. c. If you alter the number of choices, just remember that the larger number ("11" in this case) must be larger by "1" than the last option. The line reads: "EXcept when the choice is larger than '0' and less than '11' jump to 'WRONG'." If we choose "15", we jump to "wrong", get a .CS (Clear Screen) and a chance to try again1 d. The "10" is equal to the largest number you have, or the "quit" option. e. .CS means "Clear Screen." In this case its purpose is to make room for the next message which is "N O W P R I N T I N G" and really serves no useful purpose. f. .FI means "File Insert." The variable "&CHOICE&" equates to the number of your choice, so the file that is inserted (for printing) is the one having the number you chose. Example: Select #2 and FILE.2 is printed. g. The "10" is always equal to the largest number in your menu. What the line says is "If your choice is larger than "0" and less than "10" jump to REPEAT. h. REPEAT gives us first a clear screen, then a file insert - MENU - which starts us all over again.) When we choose to quit, we get instructions on the screen about how to get back to WordStar. Here is FILE.1: .op .mt 0 .pf off .po 3 Mabel Smith 12 34th Street Somewhere, Somestate 98765 Archie Able 123 97th Ave. Hereandthere, OK 76666 .pa ---------------------------------------------------------------- FILE.2 and FILE.3 are set up in exactly the same form. FILE.4 will print us a string of five labels, so its format is different. Look at the next page. .mt 2 .op .po 2 .cw 9 Frank S. Doggett 456 78th Street Springfield, CA 98777 Frank S. Doggett 456 78th Street Springfield, CA 98777 Frank S. Doggett 456 78th Street Springfield, CA 98777 Frank S. Doggett 456 78th Street Springfield, CA 98777 Frank S. Doggett 456 78th Street Springfield, CA 98777 .pa ---------------------------------------------------------------- Some notes about MENU: There are those among us who know how - and like - to write programs. I am not one of those! I am content (thus far, at least) to use the programs someone else has produced. In the case of MENU, though, we have made a kind of a program. Since I'm not a programmer, I take refuge in the fact that the real program is MailMerge. I've just put some of Mailmerge's talents to work in a way most of us don't use. Let's see how many options (selections) we can use. We are limited first by the number of columns on our screen. If we can limit the width of each of our columns of selections (including the two digits for each selection) to 25, we could get three columns of selections and still have a blank space between col umns. Now, how many lines? We'll have to save one for the heading and one for the instruction, and allow 2 for the lines that dress the menu up a bit. We have about 22 lines on our screen that we can use, so if we save four for the essentials we just discussed we can use 18 for our options. We can apply a little fundamental mathematics to the facts we've just uncovered: 18 lines per column x 3 columns = 54 total options of which one (#54) is reserved for "QUIT." That isn't too bad, considering many computers limit the file directory to 64 entries. It is not likely that the disk capacity will be ex ceeded because most of the individual files will only occupy the minimum (2K) of space per file. Remember that you must save directory space for MENU and for the .BAK file that is generated whenever you update a file. It's kind of nice to have a disk- maintenance program (e. g., NS2) on the disk, too. So there you have it! My suggestion is this: Copy MENU and the "selection" files to another disk. Rework the copied files to suit your needs (or wants) and give a try. Good Luck!