From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/50167 Path: news.gmane.org!not-for-mail From: Wolfgang Schuster Newsgroups: gmane.comp.tex.context Subject: Re: Multiple letters Date: Sun, 10 May 2009 15:01:46 +0200 Message-ID: References: <6608E28C-6DB7-4683-B174-5F359134A298@gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v930.3) Content-Type: text/plain; charset="windows-1252"; Format="flowed"; DelSp="yes" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1241960597 32298 80.91.229.12 (10 May 2009 13:03:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 10 May 2009 13:03:17 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun May 10 15:03:08 2009 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1M38gN-0002YQ-GO for gctc-ntg-context-518@m.gmane.org; Sun, 10 May 2009 15:03:07 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 894181FCE9; Sun, 10 May 2009 15:03:06 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 19779-09-3; Sun, 10 May 2009 15:02:29 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id BAA501FC57; Sun, 10 May 2009 15:02:29 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 59D001FC51 for ; Sun, 10 May 2009 15:02:28 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 19779-09-2 for ; Sun, 10 May 2009 15:02:18 +0200 (CEST) Original-Received: from filter4-til.mf.surf.net (filter4-til.mf.surf.net [194.171.167.220]) by ronja.ntg.nl (Postfix) with ESMTP id F209B1FC45 for ; Sun, 10 May 2009 15:02:17 +0200 (CEST) Original-Received: from mail-fx0-f176.google.com (mail-fx0-f176.google.com [209.85.220.176]) by filter4-til.mf.surf.net (8.13.8/8.13.8/Debian-3) with ESMTP id n4AD2GTC004610 for ; Sun, 10 May 2009 15:02:17 +0200 Original-Received: by fxm24 with SMTP id 24so2359174fxm.2 for ; Sun, 10 May 2009 06:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=Hp5OD/GSKHxv/5i0XO+1LMkf970SHDiraIPCG5KFWYM=; b=oZASygHi6tuIhtQD3YKjdkm9sEgOaaYvgkBGOsQhSlHyjBcaqsNg0+MtMYEs7EJSti oiEMXbTLHLFsg96g4mgmr/0XbasOr/X23gQI6PRblLIvyrqBfJFREEBWkk5Zh/4YGe4P 3dLb7yqnH/ONdNt+SnOV93sHNQ86P0944Hwik= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=ATTvDf8Slb+iChhlNjDwQB+NWd9jw8pmYaTkJHlOGyNTCoG+6UVU7AtfVmuyXaTStH NuFUVWt+NFfHj4OiQ0bBbNgB4lg/5rFpbW9vYD4Wu7chep4Bka5pxJcnr2UDMu5M2LQf lzDt5pLHKyiczOwl+uCMrOOC2TCIp4/79R6U0= Original-Received: by 10.86.1.18 with SMTP id 18mr5460798fga.19.1241960536816; Sun, 10 May 2009 06:02:16 -0700 (PDT) Original-Received: from ?10.40.55.99? ([82.113.121.147]) by mx.google.com with ESMTPS id d4sm4928862fga.24.2009.05.10.06.02.14 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 10 May 2009 06:02:16 -0700 (PDT) In-Reply-To: <6608E28C-6DB7-4683-B174-5F359134A298@gmail.com> X-Mailer: Apple Mail (2.930.3) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=209.85.220.176; country=US; region=CA; city=Mountain View; postalcode=94043; latitude=37.4192; longitude=-122.0574; metrocode=807; areacode=650; http://maps.google.com/maps?q=37.4192,-122.0574&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 222430065 - 82ba81290457 - 20090510 X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.220 X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.11 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:50167 Archived-At: Am 10.05.2009 um 14:32 schrieb Otared Kavian: > Hi all, > > I have to write a letter to a few dozens candidates in which some = > parts are not identical. I may have the list of the persons, and the = > changing part for each of them in a file (named for instance "list- = > of-candidates.tex") on which each line corresponds to one person and = > the fields are sperated by commas (or any other suitable character). = > What would be the best way of coding this in ConTeXt? > > Here is the example I have in mind: > > %%% begin the body of the letter > > Dear \MmeOrSir\ \FirstName\ \FamilyName, > > We have received your application and we thank you for your interest = > in our institution. > \AnswerToApplication. > > With our best regards, etc=85 > > %%% end the body of the letter > > The four commands \MmeOrSir, \FirstName, \FamilyName, = > \AnswerToApplication should correspond to the columns 1 through 4 of = > each line of the file > "list-of-candidates.tex" as follows: > > %%% begin list-of-candidates.tex > Madam , Joan , of Arc , {You will be interviewed very soon} > Mr , Groucho , Marx , {We are sorry, but this position is only for = > non smoking candidates} > > \endinput > %%% end list-of-candidates.tex > > Thank you for help: OK \unprotect \definemessageconstant {filecontents} \startmessages all library: filecontents title: filecontents 1: Overwriting file -- 2: Writing file -- \stopmessages \def\startfilecontents {\begingroup \protectbuffersfalse \dostartfilecontents} \def\dostartfilecontents[#1]% {\doiffileexistselse{#1} {\showmessage\m!filecontents{1}{#1}} {\showmessage\m!filecontents{2}{#1}}% \beforesplitstring#1\at.\to\filename \aftersplitstring #1\at.\to\extension \let\f!temporaryextension\extension \dostartbuffer[\filename][startfilecontents][stopfilecontents]} \def\stopfilecontents {\doifmode{mkiv}{\savebuffer[\filename]\ctxlua{file.copy("\jobname- = \filename.tmp","\filename.\f!temporaryextension")}}% \endgroup} \ifx\savebuffer\undefined \def\savebuffer[#1] = {\ctxlua{buffers.save("#1")}} \fi \protect \startfilecontents[data.dat] Madam, Joan, of Arc, {You will be interviewed very soon} Mr, Groucho, Marx, {We are sorry, but this position is only for non = smoking candidates} \stopfilecontents \usemodule[database,letter] \define[4]\createletter {\startletter[opening=3D{Dear #1 #2 #3,}] We have received your application and we thank you for your = interest in our institution.\endgraf #4 \stopletter} \defineseparatedlist [LETTER] [command=3D\createletter, separator=3D{,}] \starttext \processseparatedfile[LETTER][data.dat] \stoptext Wolfgang ___________________________________________________________________________= ________ If your question is of interest to others as well, please add an entry to t= he Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-cont= ext webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________= ________