From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/38596 Path: news.gmane.org!not-for-mail From: Carsten Fechtmann Newsgroups: gmane.comp.tex.context Subject: Bug or feature? Strange counter behaviour in macro Date: Fri, 11 Jan 2008 19:13:04 +0100 Message-ID: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v915) Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1200125822 7721 80.91.229.12 (12 Jan 2008 08:17:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 12 Jan 2008 08:17:02 +0000 (UTC) To: ntg-context@ntg.nl Original-X-From: ntg-context-bounces@ntg.nl Sat Jan 12 09:17:24 2008 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 1JDbYR-0007uw-1h for gctc-ntg-context-518@m.gmane.org; Sat, 12 Jan 2008 09:17:23 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id CB9D21FBF6; Sat, 12 Jan 2008 09:16:58 +0100 (CET) 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 07992-01-2; Sat, 12 Jan 2008 09:16:19 +0100 (CET) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 6A6211FBC5; Sat, 12 Jan 2008 09:16:19 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id C90721FBEB for ; Fri, 11 Jan 2008 19:13:44 +0100 (CET) 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 19477-04-8 for ; Fri, 11 Jan 2008 19:13:09 +0100 (CET) Original-Received: from www.zarm-technik.de (zarm5.zarm.uni-bremen.de [134.102.236.5]) by ronja.ntg.nl (Postfix) with ESMTP id 399251FB74 for ; Fri, 11 Jan 2008 19:13:09 +0100 (CET) Original-Received: from localhost (unknown [127.0.0.1]) by www.zarm-technik.de (Postfix) with ESMTP id C0E681013B for ; Fri, 11 Jan 2008 18:13:19 +0000 (UTC) X-Virus-Scanned: amavisd-new 2.5.2 (20070627) at zarm-technik.de Original-Received: from www.zarm-technik.de ([127.0.0.1]) by localhost (www.zarm-technik.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id G9zywAWSZ4rE for ; Fri, 11 Jan 2008 19:13:17 +0100 (CET) Original-Received: from [10.0.1.2] (pD955F907.dip.t-dialin.net [217.85.249.7]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by www.zarm-technik.de (Postfix) with ESMTP id 03FFFDF78 for ; Fri, 11 Jan 2008 19:13:16 +0100 (CET) X-Mailer: Apple Mail (2.915) X-Virus-Scanned: amavisd-new at ntg.nl X-Mailman-Approved-At: Sat, 12 Jan 2008 09:16:17 +0100 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.9 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:38596 Archived-At: Hello everyone, first off: I am new to ConTeXt (even if not so new to LaTeX) and would like to transfer some of my old macros to ConTeXt... I am well aware, that this means re-programming (most) of them. So be it. Furthermore, I am not sure if this is really the right way (read = ConTeXt Way) to do it. It just looked like a good idea at the time ... However, I just hit a snuff with the following: If one places \NewIssue[Some Time] somewhere in the text, it should = result in a new (issue / timestamp) to be generated, which can then = placed in a list of issues / changes. I also want to be able to make use of the last value Issue to be = placed in the header, same goes for the last timestamp Now this is how I went out to do this in ConTeXt (maybe wrongly so?) following the manual and some examples on contextwiki %--------------- code below ----------------------- \definesynonyms[Issue][issues][\IssueText][\IssueDate] \setupsynonyms[Issue][criterium=3Dall] \newcounter\IssueCounter \definenumber[IssueNumber] \def\TempIssueText{% = %% This was the (seemingly) only way to get any value beside 0 %% from \getnumber within doAddIssue %% Original place for \incrementnumber[IssueNumber] Issue~\getnumber[IssueNumber]: } \def\NewIssue{\dosingleargument\doNewIssue} \def\doNewIssue[#1]{% \increment\IssueCounter % This one works correctly. %% Alternative place for %\incrementnumber[IssueNumber] %% if placed here instead of in \TempIssueText %% a DIFFERENT, but still wrong result comes out %% that is: Debug shows the right progression, %% but ALL "Issue x" Numbers are set to the last one Debug: \IssueCounter / \getnumber[IssueNumber]% %% but alas I can't seem to make this work with the following lines :-( \doifempty{#1}{\Issue[\IssueCounter]{\TempIssueText}{\currentdate}} \doifnotempty{#1}{\Issue[\IssueCounter]{\TempIssueText}{#1}} %% Note: Using \dofiemptyelse gives the same result, %% I just wanted to make sure here that I am /really/ not calling it = twice, %% somehow, by being able to disable each case, separately and = definitely. -- \IssueCounter / \getnumber[IssueNumber] \crlf } % -- -- -- -- -- -- \starttext \NewIssue[January 9, 2008] \NewIssue[January 10, 2008] \NewIssue % January 11, 2008 List of issue \# and dates: \placelistofissues \blank \IssueDate{\IssueCounter} % produces correct result in either case \stoptext %--------------- code above ----------------------- Result as printed out by original version ---------------------------------------------- Debug: 1/ 0 =96 1/ 0 Debug: 2/ 0 =96 2/ 0 Debug: 3/ 0 =96 3/ 0 List of issue # and dates: Issue 2: January 9, 2008 Issue 4: January 10, 2008 Issue 6: January 11, 2008 January 11, 2008 ------------------------------ So while \IssueCounter is updated correctly and used with the right = values, \getnumber[IssueNumber] always sees / reports the original value However, the value in \placelistofissues are twice what they should be?! This is changed if one places \incrementnumber[IssueNumber] INSIDE of = \doAddIssue Here, \getnumber[IssueNumber] does report the right value (same as = IssueCounter) However, in that case the result looks like this: Result as printed out by alternative version ---------------------------------------------- Debug: 1/ 1 =96 1/ 1 Debug: 2/ 2 =96 2/ 2 Debug: 3/ 3 =96 3/ 3 List of issue # and dates: Issue 3: January 9, 2008 Issue 3: January 10, 2008 Issue 3: January 11, 2008 January 11, 2008 ------------------------ In short, while now the value of \getnumber[IssueNumber] is correct = before and after, its value in \placelistofissues is always the last value, i.e. equal = to the total number of issues. And this does NOT even change, when one replaces Issue~\getnumber[IssueNumber]: Issue~\IssueCounter: in \TempIssueText So for some reason, \TempIssueText is called twice ? How? Where? Unfortunately, my ConTeXt.foo is not yet good enough to make it over = the TeX.bar here as I haven't found a way to make this work (preferably with = \IssueCounter as all this \XXXnumber stuff does not seem to work the way I think it = should, anyway...) And yes, ANY help with this is very welcome by now Sincerely Carsten P.S: Context version is 2007.01.12 15:56 / TeXlive / OS X ___________________________________________________________________________= ________ 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 ___________________________________________________________________________= ________