# multiple lists in etoolbox

I'm trying to have a number of lists using etoolbox that I process near the end of a document. There may be a large number of these lists, and I do not know how many I will have beforehand, so I have been trying to use a number in the list name to keep track of everything.

With the code below, I am probably doing something horribly wrong, it is just not obvious to me what that is.

\documentclass{article}
\usepackage{etoolbox}

\begin{document}
\csdef{foo1}{}
\csdef{foo2}{}

\dolistcsloop{\csname foo1\endcsname}

\end{document}


This print "firstsecond", but I only expected it to print "first". The same thing happens if I only try to print the second list. What do I need to change to make it behave as I would expect?

-

the ...cs... variants of the commands take the name of a macro not the macro itself, so you don't want those \csname (they are added internally)

\documentclass{article}
\usepackage{etoolbox}

\begin{document}
\csdef{foo1}{}
\csdef{foo2}{}


And the two \csdef seem unnecessary. –  egreg Jun 13 '12 at 22:21