From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/32402 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: Sun, 31 Dec 2006 12:52:07 -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> <459772F9.8070501@gmx.net> 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 1167587556 20884 80.91.229.12 (31 Dec 2006 17:52:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 31 Dec 2006 17:52:36 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Sun Dec 31 18:52:35 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 1H14rC-0008E1-N9 for gctc-ntg-context-518@m.gmane.org; Sun, 31 Dec 2006 18:52:26 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id E745920051; Sun, 31 Dec 2006 18:50:04 +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 01352-02; Sun, 31 Dec 2006 18:49:56 +0100 (CET) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 460261FFE7; Sun, 31 Dec 2006 18:49:56 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id E1B8D1FFEC for ; Sun, 31 Dec 2006 18:49:53 +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 01358-01-3 for ; Sun, 31 Dec 2006 18:49:48 +0100 (CET) Original-Received: from skycaptain.mr.itd.umich.edu (smtp.mail.umich.edu [141.211.93.160]) by ronja.ntg.nl (Postfix) with SMTP id E04141FFD4 for ; Sun, 31 Dec 2006 18:49:47 +0100 (CET) Original-Received: FROM aditya.annarb01.mi.comcast.net (c-68-40-50-205.hsd1.mi.comcast.net [68.40.50.205]) BY skycaptain.mr.itd.umich.edu ID 4597F8C6.8F466.1280 ; 31 Dec 2006 12:52:07 -0500 Original-To: mailing list for ConTeXt users In-Reply-To: <459772F9.8070501@gmx.net> 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:32402 Archived-At: On Sun, 31 Dec 2006, Thomas Engel wrote: > Aditya Mahajan wrote: > > > \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 > > > Thanks for your help. It's great! > > What I recognized is when I put this on layer for better placement of > the header it doesn't work. > Here is an example: > > \def\Schulaufgabekopf% > {\bf \tfa > \setupTABLE[option=stretch] > \setupTABLE[frame=off] > \setupTABLE[column][1][width=0.7\textwidth] > \setupTABLE[column][2][width=0.3\textwidth] > > \setupTABLE[row][2,3,4][background=color,backgroundcolor=gray,frame=off] > \setupTABLE[row][5][height=1cm] > \bTABLE > \bTR \bTD \strut \eTD \bTD \strut \eTD \eTR > \bTR \bTD \AAnr \eTD \bTD Date: \eTD \eTR > \bTR \bTD Name: \eTD \bTD Points: \hfill of \nofPoints \eTD\eTR > \bTR \bTD Form: \Klnr \eTD \bTD Mark: \eTD \eTR > \bTR \bTD [nc=3, align=low] \tfxx Unterschrift eines > Erziehungsberechtigten: \thinrule \eTD \eTR > \eTABLE} > > \definelayer[kopf][width=\paperwidth, height=\paperheight] > > %Klassenarbeiten Kopf > \def\AAnr{2. Schulaufgabe Englisch 2006/2007} > \def\Klnr{10 \hfill} > %\definelogo[SAK] [top][left][command=\Schulaufgabekopf] > %\placelogos[SAK] > > > \setlayer[kopf][x=1.9cm, y=1cm]{\Schulaufgabekopf} Change this line to \appendtoks \setlayer[kopf][x=1.9cm, y=1cm]{\Schulaufgabekopf} \to \everystarttext or \appendtoks \setlayer[kopf][x=1.9cm, y=1cm]{\Schulaufgabekopf} \to \everyafterutilityread > \setupbackgrounds[page][background=kopf] > \starttext > > % Lets set 10 problems with different points > \dorecurse{10} > {\pkt[\recurselevel] \input tufte \endgraf} > > \stoptext > > What's going wrong? The layer kopf is being set before the tui file is read. So, the value of \nofPoints is still 0. You need to set this layer after the utility file is read by appending the code to \everyafterutilityread or to \everystarttext (which happens after reading utility file). Aditya