Aditya Mahajan wrote:
>
> 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
>   
you probably have subpage numbers in the back of your mind since they 
use two pass lists
> % 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?
>   
i've added:

\def\incrementcounter#1#2% #1 name #2 value
   {\setxvalue{#1}{\the\numexpr\csname#1\endcsname+#2\relax}}

\def\decrementcounter#1#2% #1 name #2 value
   {\setxvalue{#1}{\the\numexpr\csname#1\endcsname-#2\relax}}

(increment is used elsewere too)
> % 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?
>   
everystoptext is more tricky and cannot be handled in the nested case; 
starttext is less tricky ; both are only expanded once 

Hans  

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

Reply via email to