From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/84748 Path: news.gmane.org!not-for-mail From: Philipp Gesang Newsgroups: gmane.comp.tex.context Subject: Re: Code Called Twice? Date: Sat, 12 Oct 2013 02:09:01 +0200 Message-ID: <20131012000901.GB24051@tartaros> References: <20131011110031.GA22197@tartaros> <52586D9C.4030004@wxs.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2128140913==" X-Trace: ger.gmane.org 1381536546 16017 80.91.229.3 (12 Oct 2013 00:09:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 12 Oct 2013 00:09:06 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sat Oct 12 02:09:11 2013 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([5.39.185.229]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VUmlb-0005i4-5X for gctc-ntg-context-518@m.gmane.org; Sat, 12 Oct 2013 02:09:11 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 1B8F4101F0; Sat, 12 Oct 2013 02:06:34 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id qV8VxztMwtZn; Sat, 12 Oct 2013 02:06:31 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id 2E4BC101E6; Sat, 12 Oct 2013 02:06:31 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 2970E101E6 for ; Sat, 12 Oct 2013 02:06:29 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id fTUCKe2Npk0R for ; Sat, 12 Oct 2013 02:06:28 +0200 (CEST) Original-Received: from filter5-til.mf.surf.net (filter5-til.mf.surf.net [194.171.167.221]) by balder.ntg.nl (Postfix) with ESMTP id EA3F3101E5 for ; Sat, 12 Oct 2013 02:06:27 +0200 (CEST) Original-Received: from relay2.uni-heidelberg.de (relay2.uni-heidelberg.de [129.206.210.211]) by filter5-til.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id r9C092l0015033 for ; Sat, 12 Oct 2013 02:09:03 +0200 Original-Received: from ix.urz.uni-heidelberg.de (cyrus-portal.urz.uni-heidelberg.de [129.206.100.176]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r9C0901k027203 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 12 Oct 2013 02:09:02 +0200 Original-Received: from extmail.urz.uni-heidelberg.de (extmail.urz.uni-heidelberg.de [129.206.100.140]) by ix.urz.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r9C0908r019338 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 12 Oct 2013 02:09:00 +0200 Original-Received: from localhost (p4FFFD17E.dip0.t-ipconnect.de [79.255.209.126]) (authenticated bits=0) by extmail.urz.uni-heidelberg.de (8.13.4/8.13.1) with ESMTP id r9C08wHP030951 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Sat, 12 Oct 2013 02:08:59 +0200 Mail-Followup-To: mailing list for ConTeXt users In-Reply-To: <52586D9C.4030004@wxs.nl> X-Operating-System: Linux tartaros 3.9.6-1-ARCH User-Agent: Mutt/1.5.21 (2010-09-15) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=129.206.210.211; country=DE; region=01; city=Heidelberg; latitude=49.4167; longitude=8.7000; http://maps.google.com/maps?q=49.4167,8.7000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0WKA093fh - 82f376415a9f - 20131012 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.221 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:84748 Archived-At: --===============2128140913== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="DBIVS5p969aUjpLe" Content-Disposition: inline --DBIVS5p969aUjpLe Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable =C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7 > On 10/11/2013 1:00 PM, Philipp Gesang wrote: > > =C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7 > > > >> > >> I noticed something unexpected with the following code: > >> > >> \enabletrackers[metapost.showlog] > >> > >> \startuseMPgraphic{heading:ThemeTitleStyle} > >> show "HEADING:THEMETITLESTYLE"; > >> show \MPstring{heading:title}; > >> > >> draw textext( \MPstring{heading:title} ) rotated 5 > >> withcolor blue; > >> \stopuseMPgraphic > >> > >> \defineframed[ThemeTitleStyle][ > >> background=3D\useMPgraphic{ThemeTitleStyle}, > >> ] > >> > >> \def\processword#1{% > >> \setMPtext{heading:title}{#1}% > >> \useMPgraphic{heading:ThemeTitleStyle} > >> } > >> > >> \define[1]\ThemeChapterTitle{\applytosplitstringword\processword{#1}} > >> \setuphead[chapter][deeptextcommand=3D{\ThemeChapterTitle}] > >> > >> \starttext > >> \startchapter[title=3DWhy Is heading:ThemeTitleStyle Called Twice?] > >> \input knuth > >> \stopchapter > >> \stoptext > >> > >> It appears as though heading:ThemeTitleStyle is being called twice: > >> > >> metapost > info: > >>>> "HEADING:THEMETITLESTYLE" > >>>> "Why" > >> metapost > info: > >>>> "HEADING:THEMETITLESTYLE" > >>>> "Why" > >> > >> I am trying to produce a random number that is not equal to the > >> previous random number. However, if the code is called twice, then I'd > >> have to add code to ignore one of the calls. > >> > >> Any ideas why the code seems to be called twice and what can be done > >> to ensure that it is only called once? > > > > Don=E2=80=99t use text ;-) That=E2=80=99s a known issue: as soon as you= r Metapost > > code contains text, it will be processed twice. E.g.: > > > > > > \starttext > > \setMPtext{heading:title}{foo} > > \startMPcode > > show "This gets printed twice."; > > draw textext( \MPstring{heading:title} ); > > \stopMPcode > > \stoptext > > > > Same for labels, {b,e}tex. See also this thread: > > > > http://www.ntg.nl/pipermail/ntg-context/2011/056047.html >=20 > you can check for it: >=20 > \enabletrackers[metapost.showlog] >=20 > and in the mp code: >=20 > message(if mfun_first_run : "first run" else : "final run" fi) ; > message(if mfun_trial_run : "trial run" else : "final run" fi) ; >=20 > Hans That=E2=80=99s handy! I added a section on dealing with multi-pass to the =E2=80=9Cgotchas=E2=80=9D page: http://wiki.contextgarden.net/Unexpected_behavior#Multipass There is a subsection about MP at the end. Btw. the behavior of mfun_trial_run is not very intuitive. I=E2=80=99d expect it to work like \iftrialtypesetting, but in a single-pass context it evaluates to true: \enabletrackers[metapost.showlog] \starttext \startMPcode if mfun_trial_run : show "This should be printed during the trial pass."; else : show "This should be printed during the final pass."; fi; fill unitcircle scaled 1cm withcolor blue; %label (btex Some label text etex, (0,0)); \stopMPcode \stoptext Uncommenting the label yields two passes, as expected. Best regards, Philipp --DBIVS5p969aUjpLe Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.21 (GNU/Linux) iQEcBAEBAgAGBQJSWJMcAAoJEI7yfcKNwM1+CzkH/jOl9Pame4fQwg6V5Io8yV6/ gDZ3NgC9MQ0DaZk71tQEekpg7CjtcmUS57sazoHrk4p7O4fHzs4ihY9sw5oU8h5k 8nb1a7zsKxPsKTswjBBSCCr4x2dxFlo0RWrsKhy5EqoHu5hEHFWOHhjgLWfqguVO bqBX+zVF0R8YIk5/r6gwacWmdLpA/ugDPiWz36skB/5SXnhrxTPF2tLLyivPevqe xdxxNMMbZ57K0cZ5I+DUEwlr7Uf1lGRBs3oMsULzxDwLEf2EHIkDMI5zyPVYp7sw vRZp6Ozh0xXq2fqVp7K7+fNXCIYJcIMNWndI0e1hIa1ZSpzxAV7wJoAJKJffh/M= =oDOR -----END PGP SIGNATURE----- --DBIVS5p969aUjpLe-- --===============2128140913== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ --===============2128140913==--