🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #2130

Re: Using an input file with a letter template file

#2130
From: Robert Inder
Date: Wed, 12 Aug 1992 09:49
79 lines
2968 bytes
In article <BsnEyo.6st@cpsc.ucalgary.ca> suchitra@cpsc.ucalgary.ca (Suchitra Chander) writes:


   Hi,
     I do not have much information on the letter document style. 
   I know how to set it up, but how would I incoporate the use of several 
   different (recipient) addresses, so that I can generate several form-letters
   (simultaneously), using one file?
     Is it possible to make one input file with recipient addresses and use it 
   with a letter template file as in WordPerfect and common word-processors ?
     Thank you,

I've done this reasonably painlessly.  I won't swear that I did it
the best way, but it worked.  Instead of just putting the text of the
letter between "\begin{letter}" and "\end{letter}", I put the whole thing
within another command, which I called "\arecipient", that took more
arguments.  Then I used those arguments to re-bind various parameters used
within the letter.  Then, the actual mailing list was simply a list of
calls to "\arecipient" with the relevant details.

So the whole thing looked roughly like this:


    \documentstyle[12pt,a4wide]{letter}
    \begin{document}
       .
       .
       normal command definitions and other gubbins
       .
       .
    \newcommand{\Who}{Formal Name}
    \newcommand{\who}{Name}
    \newcommand{\company}{Company Name}
    \newcommand{\where}{Company Address}
    \newcommand{\what}{Company Products}

    \newcommand{\arecipient}[5]{
    \renewcommand{\Who}{#1}
    \renewcommand{\who}{#2}
    \renewcommand{\company}{#3}
    \renewcommand{\where}{#4}
    \renewcommand{\what}{#5}
    \begin{letter}{\Who \\ 
		   \company \\
		   \where}
    \opening{Dear \who,}
    Here is a letter to ask for details about \what.  I hope you
    can supply them.
    \closing{Cheers, squire}

    \end{letter}

    \include{mailing-list}

    \end{document}


With the mailing list file looking something like

    \arecipient{Mr. Pooh Bear}{Pooh}
	    {WTP Enterprises}
	    {Under the name of Saunders, 100 Acre Wood}
	    {your course on Honey Eating for beginners}
    \arecipient{Mrs. Roo}{Kanga}
	    {Roo and Offspring}
	    {100 Acre Wood}
	    {your range of pouch liners and fasteners}
	.
	.
	.


Hope this helps.

Robert.
--
--------------------------------------------------------------------------
Robert Inder        HCRC, 2, Buccleuch Place, Edinburgh  EH8 9LW Scotland 
Technical Details
Message-ID: <ROBERT.92Aug12104922@compton.cogsci.ed.ac.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!edcastle!edcogsci!cogsci!robert
References: <BsnEyo.6st@cpsc.ucalgary.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!edcastle!edcogsci!cogsci!robert
From: robert@cogsci.ed.ac.uk (Robert Inder)
Newsgroups: comp.text.tex
Subject: Re: Using an input file with a letter template file
Message-ID: <ROBERT.92Aug12104922@compton.cogsci.ed.ac.uk>
Date: 12 Aug 92 09:49:22 GMT
References: <BsnEyo.6st@cpsc.ucalgary.ca>
Sender: robert@cogsci.ed.ac.uk
Organization: Centre for Cognitive Science, University of Edinburgh
Lines: 79
In-reply-to: suchitra@cpsc.ucalgary.ca's message of 8 Aug 92 04:54:21 GMT