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
   [EMAIL PROTECTED]
\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
_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

Reply via email to