I want to create an array containg specific values of a counter to be used in a foreach loop. So I want to define a command that adds the actual counter value at the end of the list. What I can do is:
\documentclass{standalone}
\usepackage{pgfmath,pgffor}
\begin{document}
\def\names{{"Katie","Frank","Laura","Joe"}}%
\newcounter{lines}%
\setcounter{lines}{3}%
\def\arr{1,\arabic{lines}}%
\foreach \i in \arr {%
Name \i: \pgfmathparse{\names[\i]}\pgfmathresult, }
\end{document}
But what I need is an empty list arr and a function that I can use to fill arrwith values of lines like e.g. \addtoarr{\arabic{lines}}.
I tryed using the lstdock package like:
\let\arr\@empty
\def\addtolist#1#2{%
\lst@lAddTo#1{#2}}
\addtolist{\arr}{\arabic{lines}}
But this gives me an error I don't understand.
