From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/30215 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: how to figure out the number of elements inside \defineconversion? Date: Thu, 10 Aug 2006 17:22:38 +0200 Message-ID: <44DB4F3E.20203@wxs.nl> References: <6faad9f00608100716l5715b634p51f823f76ac51221@mail.gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1155223405 5329 80.91.229.2 (10 Aug 2006 15:23:25 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 10 Aug 2006 15:23:25 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Thu Aug 10 17:23:22 2006 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 ciao.gmane.org with esmtp (Exim 4.43) id 1GBCN1-0003iu-Je for gctc-ntg-context-518@m.gmane.org; Thu, 10 Aug 2006 17:22:51 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id AFA811FECE; Thu, 10 Aug 2006 17:22:50 +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 19454-05; Thu, 10 Aug 2006 17:22:46 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id EC6851FEB1; Thu, 10 Aug 2006 17:22:45 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 141FC1FEB1 for ; Thu, 10 Aug 2006 17:22:44 +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 19524-05-2 for ; Thu, 10 Aug 2006 17:22:42 +0200 (CEST) Original-Received: from mail.pragma-ade.net (dsl-083-247-100-017.solcon.nl [83.247.100.17]) by ronja.ntg.nl (Postfix) with SMTP id 4155B1FE96 for ; Thu, 10 Aug 2006 17:22:42 +0200 (CEST) Original-Received: from [10.100.1.102] (unverified [10.100.1.102]) by controller-1 (SurgeMail 3.7b8) with ESMTP id 689 for ; Thu, 10 Aug 2006 17:22:42 +0200 User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) Original-To: mailing list for ConTeXt users In-Reply-To: <6faad9f00608100716l5715b634p51f823f76ac51221@mail.gmail.com> X-Server: High Performance Mail Server - http://surgemail.com r=-274017400 X-Authenticated-User: hagen@controller-1 X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 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:30215 Archived-At: Mojca Miklavec wrote: > Hello, > > I would like to \defineconversion and the use that set of symbols > inside a metapost graphic. But I need to know the number of symbols, > so that I can define enough "metapost images with symbols" in advance. > I realise that there might be a problem since conversion can sometimes > take an arbitrary number (using a command defined elsewhere), but if I > could have a reasonable guess for conversions defined explicitely, > that would already help a lot. (As a workaround and/or if there is no > easy method to figure that out I can still hardcode "25" and wait > until someone complains that that is not enough to satisfy his/her > needs.) > > Thanks a lot, > Mojca > > > \startMPextensions > numeric variant; variant = 1; > vardef gp_the_symbol(expr n) = > picture pict; > % using metapost > if variant=1: > pict := image( fill fullcircle scaled 4pt; ); % TODO > % using TeX, variant = 2 > else: % TODO: limit the number first > pict := sometxt(n); > fi; > pict shifted -center pict > enddef ; > > def gp_point(expr x, y, n) = > draw (gp_the_symbol(n) scaled 1 shifted (x,y)); > enddef ; > \stopMPextensions > > \starttext > > \defineconversion[abc][$\star$,$\bullet$,$\ast$] > > \startTeXtexts > % TODO: 6 is only a guess: I need a better guess (3 in this case) > \dostepwiserecurse{1}{6}{1}{\TeXtext{\recurselevel}{{\convertnumber{abc}{\recurselevel}}}} > \stopTeXtexts > > \startMPcode > variant := 1; > gp_point(1cm,0cm,1); > gp_point(2cm,0cm,2); > variant := 2; > gp_point(1cm,1cm,1); > gp_point(2cm,1cm,2); > gp_point(3cm,1cm,3); > gp_point(4cm,1cm,4); > gp_point(5cm,1cm,8); > \stopMPcode > > \stoptext > \unprotect \def\doifelseconversionnumber#1#2% {\doifdefinedelse{\??cv#1#2}} \protect \defineconversion[abc][$\star$,$\bullet$,$\ast$] \defineconversion[def][m,o,j,c,a] \doloop {\doifelseconversionnumber{abc}{\recurselevel} {[abc \recurselevel\space defined]} {\exitloop}} \doloop {\doifelseconversionnumber{def}{\recurselevel} {[def \recurselevel\space defined]} {\exitloop}} ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------