On Thu, 14 Dec 2006, Michael wrote:
How do I use counter in ConTeXt?
Specifically, I use this to define '\startproblem\stopproblem'.
\defineenumeration[problem][location=top,text=Problem,% between=\blank,before=\blank,after=\page]
I want to say \totalnumberofproblems, in the beginning of the exam, like \totalnumberofpages. How do I do that?
You need to have a two pass mechanism for this. Save the number of problems in the tui/tuo file in the first run and read the corresponding values from the file in the second run. Here is a simple example \defineenumeration[problem][location=top,text=Problem,% between=\blank,before=\blank] \def\nofproblems{0} \definetwopasslist {problems} \def\checkproblems {\gettwopassdata{problems} \iftwopassdatafound \xdef \nofproblems {\twopassdata} \fi \global\let\checkproblems\relax} \starttext \checkproblems This paper has \nofproblems\ Problems. \dorecurse{10} {\startproblem test \stopproblem} \savetwopassdata {problems} {\nofproblems} {\getnumber[problem]} \stoptext HTH, Aditya