From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/50168 Path: news.gmane.org!not-for-mail From: Otared Kavian Newsgroups: gmane.comp.tex.context Subject: Re: Multiple letters Date: Sun, 10 May 2009 15:29:51 +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 1241962276 3668 80.91.229.12 (10 May 2009 13:31:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 10 May 2009 13:31:16 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun May 10 15:31:06 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 1M397R-0003dc-SN for gctc-ntg-context-518@m.gmane.org; Sun, 10 May 2009 15:31:05 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 8AF171FDD8; Sun, 10 May 2009 15:31:05 +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 19781-10-2; Sun, 10 May 2009 15:30:16 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id F20E71FD7B; Sun, 10 May 2009 15:30:15 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 51C801FD79 for ; Sun, 10 May 2009 15:30:14 +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 19781-10 for ; Sun, 10 May 2009 15:29:54 +0200 (CEST) Original-Received: from filter3-ams.mf.surf.net (filter3-ams.mf.surf.net [192.87.102.71]) by ronja.ntg.nl (Postfix) with ESMTP id B1FE71FD7B for ; Sun, 10 May 2009 15:29:54 +0200 (CEST) Original-Received: from mail-ew0-f173.google.com (mail-ew0-f173.google.com [209.85.219.173]) by filter3-ams.mf.surf.net (8.13.8/8.13.8/Debian-3) with ESMTP id n4A1kXGK018822 for ; Sun, 10 May 2009 03:46:33 +0200 Original-Received: by ewy21 with SMTP id 21so3012992ewy.2 for ; Sun, 10 May 2009 06:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.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=hpjBo7aATItwQauYdhf3ca9jULum2C0Rrlv42SPf+7A=; b=vNlnYnABkBsb5LXZiuoEZ4HqxrtwX51aNh2xqWrUJiED3XwNIU5flAPWlUHjkTkVB6 BJ3A4NTopsx5dALgEs+woXIYj/CvXzP2Sfzjk+4gNIhH+Fx0qECU54lf4/Xcz04yjnJb 0Sh01wO31yzclDASabhGHidT9OMjcbpIkXVj4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=Gps2B0urTcu/ZRj/QkIZp2kTSTVyncLr5UNyd1RpbT1nB8H4WmSufnXeeuT66ZPD2S jTinnJOMin7A7fbq6/AaZHNtNYdEcHY06lutVIo+IMwV0jKp8dfnC5p/fpkmJv4zdFzN cyivfBpmnUKX6AJMWBrA9ejGnl9qVVbWby3Ds= Original-Received: by 10.210.43.10 with SMTP id q10mr4900114ebq.43.1241962193796; Sun, 10 May 2009 06:29:53 -0700 (PDT) Original-Received: from ?192.168.0.11? (mna75-3-82-66-231-76.fbx.proxad.net [82.66.231.76]) by mx.google.com with ESMTPS id 28sm1548276eyg.4.2009.05.10.06.29.52 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 10 May 2009 06:29:53 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.930.3) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=209.85.219.173; 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: 222436102 - 9d041e7ccf10 - 20090510 X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.71 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:50168 Archived-At: Dear Wolfgang, Many thanks! As usual you are clear and sharp=85 Your code works and does exactly what I need=85 Moreover I learned from = it several "clean" tricks in order to use the way one can write macros = in ConTeXt. I have just to understand different parts of the code in order to = wikify it. Best regards: OK On 10 mai 09, at 15:01, Wolfgang Schuster wrote: > > 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 the Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-co= ntext > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : https://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > _________________________________________________________________________= __________ ___________________________________________________________________________= ________ 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 ___________________________________________________________________________= ________