From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/32390 Path: news.gmane.org!not-for-mail From: Aditya Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: store counter or variable and reread again Date: Sat, 30 Dec 2006 18:51:34 -0500 (EST) Message-ID: References: <45941026$0$4168$ba624c82@nntp02.dk.telia.net> <459670F8.5020106@elvenkind.com> <45968AED.7040904@gmx.net> <4596E9B0.8070705@wxs.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1167522728 19270 80.91.229.12 (30 Dec 2006 23:52:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 30 Dec 2006 23:52:08 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Sun Dec 31 00:52:07 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 lo.gmane.org with esmtp (Exim 4.50) id 1H0nzc-0007c4-8f for gctc-ntg-context-518@m.gmane.org; Sun, 31 Dec 2006 00:52:00 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 1B98A200A3; Sun, 31 Dec 2006 00:49: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 18769-03; Sun, 31 Dec 2006 00:49:36 +0100 (CET) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id EC96320076; Sun, 31 Dec 2006 00:49:35 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 90B1720076 for ; Sun, 31 Dec 2006 00:49:31 +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 18781-02 for ; Sun, 31 Dec 2006 00:49:22 +0100 (CET) Original-Received: from hellskitchen.mr.itd.umich.edu (smtp.mail.umich.edu [141.211.14.82]) by ronja.ntg.nl (Postfix) with SMTP id ECFFB1FFFD for ; Sun, 31 Dec 2006 00:49:21 +0100 (CET) Original-Received: FROM aditya.annarb01.mi.comcast.net (c-68-40-50-205.hsd1.mi.comcast.net [68.40.50.205]) BY hellskitchen.mr.itd.umich.edu ID 4596FB87.6F533.4661 ; 30 Dec 2006 18:51:35 -0500 Original-To: mailing list for ConTeXt users In-Reply-To: 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:32390 Archived-At: On Sat, 30 Dec 2006, Aditya Mahajan wrote: > On Sat, 30 Dec 2006, Hans Hagen wrote: > > > how about > > > > \savecurrentvalue\SomeVar{someval} > > I was just copying the way it is done with other macros \lastpage, > etc. I will look at \savecurrentvalue also. Ahh, \lastpage uses \savecurrentvalue. I was pretty sure that I copied the twopass some time back from \lastpage. Maybe I was dreaming, maybe you are changing the internals too fast for me to keep up. Anyways, to make ammends, here is the solution using \savecurrentvalue % It may be better to use \setcounter series of macros. % First let us define a general macro for adding arbitrary number to a counter \unprotect \def\addtocounter#1#2% #1 name #2 value {\@EA\xdef\csname#1\endcsname{\the\numexpr\csname#1\endcsname+#2\relax}} \protect % To Hans and Taco: Should the above macro be added to syst-ext? % Now lets define everything in terms of ConTeXt's counter macros \makecounter{Points} % % show the points on the right side \def\showP[#1]{\inright{\hskip 10mm \framed{#1} }} \def\pkt[#1]% {\showP[#1]% \addtocounter{Points}{#1}} % \def\nofPoints{0} % Number of points from previous run \def\savenofPoints {\savecurrentvalue\nofPoints{\countervalue{Points}}} % It is a bit boring to type \savenofPoints everytime \appendtoks \savenofPoints \to \everystoptext % An example usage \starttext \title{This exam is of \nofPoints\ Points} % Lets set 10 problems with different points \dorecurse{10} {\pkt[\recurselevel] \input tufte \endgraf} \stoptext The whole things is much shorter :) Hans, I just noticed that \everystarttext is executed at the start of components and products, while \everystoptext is not. Does it make sense to define \stopcomponet and \stopproduct so that \everystoptext is executed? Aditya