When I compile this minimum LaTeX file:
\documentclass{report}
\def\defMacro#1#2{\expandafter\def\csname#1\endcsname{#2}}
\def\useMacro#1{\csname#1\endcsname}
\usepackage{pgffor}
\begin{document}
\foreach \n in {0,1,...,10}{
\defMacro{number:\n}{\n}
}
\useMacro{number:8}
\end{document}
I obtain no PDF output. What do I mistake?
etoolboxpackage provides\csdefand\csusewhich do the same as\defMacroand\useMacro. LaTeX itself defines\@namedefand\@nameuse. The\csusemacro takes care not to define the given macro (equal to\relax) if it doesn't exists. It expands to nothing in this case. – Martin Scharrer♦ Apr 20 '11 at 15:23