I would like to embed one array within another array.
The reason behind it is basically to learn how it would work. I have some ideas how to use this kind of encapsulation, but first let's see if this is possible :)
MWE
\documentclass[10pt,oneside,a4paper]{article}
\usepackage{ifthen}
\usepackage{pgffor}
\setlength\parindent{0pt}
\def\componentArray{{X-Pos},{Y-Pos},{Z-Pos},{Sicherung},{Phase},{Status}}
\def\combinedArray{{room},{\componentArray}}
\def\combinedArrayByHand{{room},{{X-Pos},{Y-Pos},{Z-Pos},{Sicherung},{Phase},{Status}}}
\newcounter{myCounter}
\newcommand{\iterateThroughUnusedCells}[1]{
\setcounter{myCounter}{1}
\foreach \elementX in #1 {
\ifthenelse{\isodd{\value{myCounter}}}{
\expandafter\gdef\expandafter\componentType\expandafter{\elementX}%
$COMPONENT:\componentType$\newline
}{
$ELEMENT_{X}:\elementX$\newline
\foreach \elementY in \elementX {
$ELEMENT_{Y}:\elementY$\newline
}
}
\stepcounter{myCounter}
}
}
\begin{document}
Embedded array:\newline
\iterateThroughUnusedCells{\combinedArray}
Copied array by hand into the other array\newline
\iterateThroughUnusedCells{\combinedArrayByHand}
\end{document}
RESULT
As you can see, the first function call doesn't work as expected whereas the injection by hand seems to work pretty well.
For me this seems to be a problem with expanding \componentArray, but when I try something like:
\def\temp{\elementX}%
\foreach \elementY in \temp {
ELEMENT\_Y:\elementY\newline
}
It still doesn't work... For me this should be the same like:
\def\combinedArrayByHand{{room},{{X-Pos},{Y-Pos},{Z-Pos},{Sicherung},{Phase},{Status}}}
But it isn't obviously...

\edef\combinedArray{{room},{\componentArray}}would expand the list so be the same as your "by hand" example.\iterateThroughUnusedCells{\combinedArray}and\iterateThroughUnusedCells{\combinedArrayByHand}it's clear that I'm aiming for the second one "edited by hand". But you are right, next time I will be more clear.