Your approach works. You only need to enclose strings by "
.
\documentclass[xcolor=pdftex]{article} %
\usepackage{pgffor}
\newcommand{\test}[1]{%
\def\x{{1,2,3,4,5,6}}%
\foreach \i in {0,...,5}{%
\pgfmathsetmacro{\entrynum}{\x[\i]}%
\pgfmathsetmacro{\entry}{#1[\i]}%
entry \entrynum\space of the argument of \texttt{\textbackslash test} is \entry\par
% in loop use something like \x[\i], #1[\i] etc
}
}
\begin{document}
\test{{"a","b","c","d","e","f"}}
\end{document}

Of course, you can define a helper that wraps the quotes around the entries.
\documentclass[xcolor=pdftex]{article} %
\usepackage{pgffor}
\makeatletter
\newcommand{\WrapQuotes}[2]{%
\def\pgf@temputila{0}%
\pgfutil@for\tikz@temp:=#1\do{%
\ifnum\pgf@temputila=1\relax
\edef#2{#2,"\tikz@temp"}%
\else
\edef#2{"\tikz@temp"}%
\def\pgf@temputila{1}%
\fi%
}}%
\makeatother
\newcommand{\test}[1]{%
\def\x{1,2,3,4,5,6}%
\WrapQuotes{#1}{\tmplst}%
\foreach \i in {0,...,5}{%
\pgfmathsetmacro{\entrynum}{{\x}[\i]}%
\pgfmathsetmacro{\entry}{{\tmplst}[\i]}%
entry \entrynum\space of the argument of \texttt{\textbackslash test} is \entry\par
% in loop use something like \x[\i], #1[\i] etc
}
}
\begin{document}
\test{{a,b,c,d,e,f}}
\end{document}
It is clear that all the actual applications shown here are not to exciting. I interpret the question as a question asking how to access the i
th element of a list of general things.
\x
as a set of numbers, and then use syntax such as\x[\i]
which I don't understand what you intend it to do.\x[\i]
is intended to use\i
as an index in to the\x
list. So the OP wants to use0
and\x[0]
(ie, 0 and 1), and then in the next loop you have\i=1
, so the OP wants1
and\x[1]
(ie, 1 and 2).