Classic Computer Magazine Archive COMPUTE! ISSUE 55 / DECEMBER 1984 / PAGE 189

IBM Personalized Form Letters

Donald B. Trivette

If you've ever needed to mail copies of the same letter to a number of people—for holiday greetings, notices of club meetings, or whatever—you'll appreciate this labor-saving program. It automatically retrieves addresses and salutations from disk and prints them atop your form letter. The program requires an IBM PC or PCjr with BASICA or Cartridge BASIC, a disk drive, and a printer. A word processor that saves standard ASCII files is recommended.

'Tis the season to be jolly. 'Tis also the season to send out holiday cards and letters. You remember Christmas letters, those mimeographed missives that let your archfriends know how well you're doing—or how well you want them to think you're doing. Perhaps you've not participated in this holiday ritual because it's just too much trouble to duplicate and address 50 letters—and besides, mimeographed letters are so impersonal.

Now, with the assistance of your IBM PC or PCjr, you too can practice creative writing. The BASIC program following this article automatically merges an address list with a letter to produce a personalized form letter. It's guaranteed to speed up your holiday correspondence and leave your recipients wondering whether they were form-lettered or not.

Of course, "IBM Personalized Form Letters" isn't limited to holiday greetings. You might use this program to contact everyone in the neighborhood about the proposed zoning change to put a nuclear waste dump adjacent to the playground, or to keep the members of the garden club or user group informed about the next meeting. If you occasionally need to send the same letter to many people, and don't want to invest in a commercial form-letter program, then read on.

Standard ASCII Files

IBM Personalized Form Letters is only 76 lines long (53 if you leave out the comments at the beginning). It uses the input from two files, files that you must create using a word processor, a text editor, or the DOS utility program EDLIN. However the files are created, they must be standard ASCII text. (Sorry, WordStar fans.)

One file contains an exact image of the letter. This means that if you're using a word processor to create the letter, you must not count on it to format the lines, insert spaces, and adjust the right margin. Instead, you must decide how many characters to put on each line of the letter; you must format it manually. If your word processor automatically wraps words from one line to another, as most do, you'll need to defeat that feature. For example, text with 50 characters on a line is about right for standard margins, so when a line of text reaches column 50, press the Enter key and start the next line. In other words, type the letter just as you would on an old-fashioned typewriter.

Personalized Form Letters is a dumb program. It won't understand the special codes that switch on boldface printing, underlining, centering, or any of the fancy things your word processor can do. It just reads a line from a file and prints it.

But it's not completely stupid, either. It does know enough to print one letter for each address in the address file. How do you signal the computer where to put the address? Insert <<>> at the proper location in the letter and the program will replace it with a four-line address, a blank line, the salutation, and another blank line. For example:

700 Maple Avenue

Anywhere, NC 27900

December 10, 1984


Hi. We've had a wonderful year …. Made so much money

that we don't know how we'll ever spend it…

By inserting a few blank lines ahead of your own address, you can position the letter so the recipient's address appears through a window envelope when the paper is folded. The program automatically reprints the first letter until you get it properly aligned. (Maybe you can find red window envelopes for the holidays.)

The Address List

The second ASCII file required by the program contains the address list. Again, you may use a word processor to build and maintain the file. Remember to press the Enter key after each line in the address. Personalized Form Letters is designed to use a four-line address and a one-line salutation. The salutation—Dear Bob & Ann,—adds a personal touch. Insert a blank line between each address/salutation group. That's to make it easier for you to separate one address from another when editing the address file. Here's an example of how two addresses would look:

Mr. and Mrs. Bob Adams
123 Main Street
Westover, NH 93939

Dear Bob and Ann,

Dr. and Mrs. Robert Brown
Apartment 203
7000 Southfork Avenue
Snake Bluff, CO 94959
Dear Bob & Carol & Ted & Alice,

Notice that the Adams' address is only three lines long, so a blank line is entered as the fourth line of their address.

Personalized Form Letters is designed to print on continuous-forms paper. Who wants to feed in 50 sheets one at a time? You do? Then insert two lines in the program:

374 PRINT "Insert paper and press any key."
375 B$ = INKEY$:IF B$ = "" THEN 375

and it will pause after printing each letter.

Type the BASIC program exactly as it's shown (we recommend using the "IBM Automatic Proofreader" to avoid typos). Save it. Then create your letter and address files as described above. Next, return to BASIC and run the program with those files as input. One important point: You must use Advanced BASIC (BASICA) or PCjr Cartridge BASIC when running this program (ordinary BASIC will result in a syntax error in line 560).

Happy holidays.

IBM Personalized Form Letters

Refer to "COMPUTE!'s Guide To Typing In Programs" before entering this listing.

IL	10	REM	IBM Personalized Form Letters
DI	30	REM	A program to print form letters using
QL	40	REM	addresses from an address file with
BE	50	REM	the following format:
NF	60	REM	Address line 1
PL	70	REM	Address line 2
AB	80	REM	Address line 3
BH	90	REM	Address line 4
HC	100	REM	Salutation
FG	110	REM	(blank line to separate one
JI	120	REM	address from another)
OK	130	REM	
L0	140	REM	The letter file is an ASCII file
MD	150	REM	containing the form letter
AA	160	REM	
IN	170	REM	Use <<>> to indicate where the
HI	180	REM	address/salutation is to appear in the
FC	190	REM	letter. The program automatically
GM	200	REM	inserts a blank line before and after
MC	210	REM	the salutation.
OJ	220	REM	
CA	230	REM	-------------
FL	270	PRINT	"IBM Personalized Form Letters"
MD	290	LINE	INPUT "Enter address filename: " ;ADD$
IN	300	LINE	INPUT "Enter letter filename : " ;LETR$
DL	310	LINE	INPUT "Enter left margin value: " ;N$
GI	320	N	= VAL(N$)
NE	330	I	= 0
DH	360	IF	I<2 THEN GOSUB 580
PF	370	LPRINT	CHR$(12) 'skip to top of page
NK	380	IF	EOF(1) THEN GOTO 350
OP	390	LINE	INPUT #1, A$
CN	400	IF	A$ = "<<>>" THEN GOSUB 440 'print address
HP	420	GOTO	380
FB	430	REM	---GOSUB to print address---
BL	440	I	= 1 + 1 'count of letters
OE	450	FOR	J = 1 TO 4 '4-line address
HG	460	IF	EOF(2) THEN PRINT:PRINT I-1; "Letters printed.":END
FI	470	LINE	INPUT #2, A$
AG	480	LPRINT	SPC(N)A$ 'print on printer
EK	490	PRINT	A$ 'print on screen
MK	520	LINE	INPUT #2, A$ 'salutation
KI	550	LINE	INPUT #2, A$ 'throw away blank line
AH	560	RETURN	380
KO	570	REM	---GOSUB to line up letter---
EN	580	IF	I <> 0 THEN GOTO 630
MN	590	PRINT	"Switch on printer and press any key to continue."
MJ	610	B$ = INKEY$:IF B$ = "" THEN GOTO 610
LI	630	LPRINT	CHR$(12)
GH	640	PRINT	STRING$(48, "*")
PC	650	PRINT	"* Is the letter properly alingned (Y/N/Esc) ? *"
BN	670	B	$ = INKEY$:IF B$ = "" THEN 670
GO	680	IF	B$ = CHR$(27) THEN END
KL	690	IF	B$ = "Y" OR B$ = "y" THEN RETURN
OF	700	IF	B$ = "N" OR B$ = "n" THEN PRINT "Make adjustments…": RETURN 310
KG	710	BEEP	:GOTO 670
HP	720	REM	---ERRORS---
FP	730	IF	ERR = 53 AND ERL = 340 THEN PRINT "Address file not found.":END
PB	740	IF	ERR = 53 AND ERL = 350 THEN PRINT "Letter file not found.":END
MM	760	END