[NTG-context] store counter or variable and reread again

Aditya Mahajan adityam at umich.edu
Sun Dec 31 00:51:34 CET 2006

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

\def\addtocounter#1#2% #1 name #2 value

% To Hans and Taco: Should the above macro be added to syst-ext?

% Now lets define everything in terms of ConTeXt's counter macros


% %   show the points on the right side
\def\showP[#1]{\inright{\hskip 10mm \framed{#1} }}


\def\nofPoints{0} % Number of points from previous run


% It is a bit boring to type \savenofPoints everytime

\appendtoks \savenofPoints \to \everystoptext

% An example usage


\title{This exam is of \nofPoints\ Points}

% Lets set 10 problems with different points
   {\pkt[\recurselevel] \input tufte \endgraf}


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?


More information about the ntg-context mailing list