# [texhax] Howto Count tokens

Tim Dijkstra newsuser at famdijkstra.org
Mon Sep 17 22:29:57 CEST 2007

Hi,

I'm pretty new to TeX programming, so my understanding of it is pretty
shallow. I'm trying to write a latex class at the moment and hit the
following problem.

I have a register created with \newtoks\list, it's content is roughly

{AA \mysep{BB \mysep CC \mysep DD} \mysep{EE} }

Now the problem is, how do I count the number of \mysep-s? I first
tried to replace all of them with a step in the counter (idea from tex
by topic)

And now the counter has a number.
But that obviously doesn't take into account the nesting. Now I could
just redefine it to:

Now I get the correct number, but now it also outputs AA BB CC DD EE.
In other words I need a way to expand the list but discard the output,
I only need the by product'.

Any ideas on this?

grts Tim

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://tug.org/pipermail/texhax/attachments/20070917/e83cbf3b/attachment.bin
`