summaryrefslogtreecommitdiff
path: root/info/digests/texhax/txh/bellmac.txh
blob: db79d857cbf992bc9ff3ac1833ee31029cc105a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
%  BELLMAC.TXH; reference in TeXhax.8724

Date:     Wed, 25 Mar 87 21:06 CST
From:     <BELL@UKANVAX.BITNET>
Subject: Form letter/mailing list processing.

        In Vol. 87, Issue 22, Eric Skinner inquires about a set of TeX
        macros which will produce form letters. I developed such a
        procedure here (in plain TeX) at the University of Kansas for use
        by our departmental secretaries, and it has been in use now for
        several months. John Lee in the October 1986 issue of TUGBoat asked
        the same question and the result was a reply which I expect to appear
        in the March 1987 TUGBoat along with another reply in LaTeX. For
        those of you who do not receive TUGBoat (or are impatient) here is
        a copy of it as I sent it. A label formatting procedure utilizing
        the same address file is also available.

                                        Ed Bell
                                        BITnet: BELL@UKANVAX
                                        SPAN:   KUPHSX::BELL

  --------------------------------------------------------------------------

\title AutoLetter: A \TeX\ form letter procedure.
\\Edwin V. Bell, II\cr
        Department of Physics and Astronomy
        University of Kansas
\endx

\pagexref{bell}

The inquiry from John Lee (\TUB, October 1986) concerning form letters was
particularly interesting to me as I had recently completed such a procedure
at the request of our office staff. The procedure (called AutoLetter) is
a ``plain'' \TeX\ procedure which requires two files, one containing a
delimited listing of names and addresses, the other a generic form letter.

Each entry in the address file is followed by a line containing a single
asterisk. The last entry must also be followed by this line, which in turn
{\it must} be followed by the end-of-file mark. Each individual entry consists
of six lines for the addressee's title, name, etc., followed by as many
address lines as desired. The lines for the addressee's name are:

\item{(1)}Title (Prof., Mr., Ms., etc.)
\item{(2)}First name/initial
\item{(3)}Name to be used as a familiar form of address.
\item{(4)}Middle name(s)/initial(s)
\item{(5)}Last/family name
\item{(6)}Additional name information (Jr., II, Esq., etc.)

\noindent
These lines are then used to reconstruct the persons name for various forms
of address (including for the address block) and to address the person formally
(Sir, Madam, Sir or Madam), familiarly (by item (3) above or, if (3) is
blank, by first name), or by title and last name. If any of these lines
are left blank, AutoLetter doesn't mind, but if the entry is irrelevant
or absent from the persons name, {\it it must still be left blank}. An example
of an address entry might be:
\begintt
Mr.
Edwin
Ed
V.
Bell
II
Department of Physics \& Astronomy
University of Kansas
Lawrence, KS\ \ \ 66045
*
\endtt

The letter file is quite simple and used macros that are the same as or
slight variations of those listed in Appendix E of {\sl The \TeX book}.
AutoLetter takes care of the placement of the date and address block (and
could as well the letterhead, although I have not yet implemented that here
as yet), so the letter file might appear as:
\begintt
\letterbody
Dear \person--

...text...

\closing
Sincerely,
...

\annotations...
\ps...

\endletter
\endtt

AutoLetter consists of two files, on the \TeX\ procedure itself, the other
containing the letter-formatting macros (and local macros, if desired).
The AutoLetter procedure looks like:
\begintt
\input letter_format

\message{+------------------------------------------+}
\message{| AutoLetter Version 1.1 -- 9 October 1986 |}
\message{+------------------------------------------+}

\newread\addressfile

\message{Enter name of file containing the addresses:}
\read-1 to\addfile
\openin\addressfile=\addfile

\message{Enter name of file containing the body of the letter:}
\read-1 to\letfile

%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
%       Now read in an entry containing the person to whom to send the letter
%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

\endlinechar=-1
\read\addressfile to\text \let\title=\text

\loop
    \read\addressfile to\text \let\firstname=\text
    \read\addressfile to\text \let\nickname=\text
    \read\addressfile to\text \let\middlename=\text
    \read\addressfile to\text \let\lastname=\text
    \read\addressfile to\text
        \ifx\text\blank\def\jr{}\else\def\jr{, \text}\fi
        \endlinechar='015
    \message{Now processing letter to \addressee.}
    \getaddress
    \doletter
      \endlinechar=-1
    \read\addressfile to\text \let\title=\text
    \ifeof\addressfile\endfalse\else\endtrue\fi
    \ifend
\repeat

\bye
\endtt

\noindent
Our local letter-formatting macros are:
\begintt
\input whatever local macro package you wish here

\twelvept    % 12-point size is so much easier to read

\hsize=6.5truein
\vsize=8.0truein
\hoffset=1.0truein
\voffset=1.5truein

\raggedbottom
\interlinepenalty=1000
\parindent=0pt
\parskip=0pt

\nopagenumbers

%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
%      Define some stuff so that the headlines will come out the way
%      we want them to be.
%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

\newbox\headbox
\headline={\ifnum\pageno>1
   {\twelverm
      \global\setbox\headbox=\vbox\bgroup%
         \leftline{\addressee}
         \leftline{\today}
         \leftline{Page \folio}\egroup}\copy\headbox
   \else\hfil\fi}

\def\makeheadline{\vbox to 0pt{\vskip-70.6pt
   \line{\vbox to30.6pt{}\the\headline}\vss}
   \nointerlineskip}

\newif\ifend

%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
%       Macros for reading in the address from the file.
%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

\def\blank{}

\def\endletter{\endmode\vfill\eject\pageno=1}

\newdimen\longindentation \longindentation=10truecm
\newbox\theaddress
\newif\ifast
\def\aster{* }
\def\getaddress{{\global\setbox\theaddress=\vbox\bgroup\raggedright%
   \hsize=\longindentation
   \everypar{\hangindent2em}
      \line{\vbox to10.2pt{}\addressee\hss}\egroup%
   {\loop{\read\addressfile to\text
      \ifx\text\aster\astfalse\else\asttrue\fi
      \ifast\global\setbox\theaddress=\vbox\bgroup\unvbox\theaddress
         \line{\vbox to 10.2pt{}\text\hss}\egroup}\repeat}}}

%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
%       Macros for formatting the letter.
%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

\def\letterbody{\beginparmode}
\def\closing{\beginlinemode\getclosing}
{\obeylines\gdef\getclosing #1
   #2
      {#1\nobreak\bigskip \leftskip=\longindentation #2
      \nobreak\bigskip\bigskip\bigskip\bigskip % space for signature
      \def
      {\endgraf\nobreak}}}
\def\annotations{\beginlinemode\def\par{\endgraf\nobreak}\obeylines\par}
\def\ps{\beginparmode\nobreak
   \interlinepenalty5000\def\par{\endgraf\penalty5000}
   P.cS.\ }

\def\address{\beginlinemode \copy\theaddress \endgroup}
\def\doletter{{\leftskip=\longindentation%
      \rm\today\bigskip\address\bigskip}
   \input \letfile}

%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
%       Macros for setting up forms of salutation.
%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

\def\mr{Mr.}
\def\ms{Ms.}
\def\mrs{Mrs.}
\def\miss{Miss}

\def\addressee{\ifx\blank\title\else\title\space\fi%
   \firstname\space\ifx\blank\middlename\else\middlename\space\fi%
   \lastname\jr}
\def\person{\ifx\blank\title Sir or Madam\else\title\space\lastname\fi}
\def\familiar{\ifx\blank\nickname \firstname\else\nickname\fi}
\def\formal{\ifx\mr\title Sir\else{\ifx\ms\title Madam\else%
   {\ifx\mrs\title Madam\else{\ifx\miss\title Madam\else{\person}\fi}%
   \fi}\fi}\fi}
\endtt

The AutoLetter procedure prompts the user for the names of the address and
letter files and then goes to work. A similar procedure (called {\smc Labels})
can also be used with the address file to produce 33 labels/page (3 columns
of 11 labels). This enables us to produce form letters with or without labels
or to maintain mailing lists without requiring letters (for abstract mailings,
for example).

If anyone is interested in having these procedures, drop me a line. If response
is high, I would be more than willing to provide them to the \TeX\ community
at large. Mail may be sent to:

\leftline{Bitnet: Bell@UKANVAX}
\leftline{SPAN: KUPHSX::Bell}

-------