I have the following nested loop situation:
\begingroup
\def\do##1{%
\begingroup
\def\do####1{%
\csletcs{somemacro@##1@####1}{someothermacro@##1@####1}}%
\dolistloop\somelista
\endgroup}%
\dolistloop\somelistb
\endgroup
where I need to have the \csletcs definition exist outside of the two groups but not globally. There is a nice trick from Martin Scharrer in a comment to this question:
How do I get a value out of a group?
but it doesn't work in a loop like this as putting the \endgroups in the inner loop really mess the next loop iterations up. Is there any way (etoolbox is ok) to get the \csletcs definitions out of the groups without breaking further iterations of the loops? I assume I need the groups otherwise the do loop arguments don't reference properly.
Just for completeness, here is an attempted solution using Martin Sharrer's trick:
\begingroup
\def\do##1{%
\begingroup
\def\do####1{%
\edef\@z{\endgroup\endgroup\csletcs{somemacro@##1@####1}{someothermacro@##1@####1}}\@z}%
\dolistloop\somelista
\endgroup}%
\dolistloop\somelistb
\endgroup
This works for the first nested iteration and the resulting cs is defined properly outside of the groups. Unfortunately, the groups are then closed and the next iterations are a real mess.
\undefit with one of the solutions from How to undo a \def (i.e., Need a \undef capability). So then it no longer exists globally. – Peter Grill Apr 05 '13 at 18:50\defing or\leting etc. outside of the inner groups? Bear in mind that I need the\doloop argument values##1and####1in the definitions and they are only available inside the two groups so I don't have the information to define the cs outside of the groups ... – PLK Apr 05 '13 at 18:55\doin order to process the "inner list"; you can use whatever command you want for processing a list, see\forlistloop. – egreg Apr 05 '13 at 19:59