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