I've got a define such as \def\doctype{SomeString}. \doctype can take on one of five values. I want to do something like a switch statement in a programming language, i.e. (pseudocode):
switch (\doctype) {
case 'SomeString1': some text here
case 'SomeString2': some different text here
...
}
(I don't need a default/else/otherwise case.) I tried doing this in LaTeX with:
\documentclass{article}
\usepackage{etoolbox}
\def\doctype{SomeString1}
\newenvironment{switchdoctype}[0]{%
\newcommand{\case}[2]{\ifdefequal{\doctype}{##1}{##2}{}}%
}{}
\begin{document}
\begin{switchdoctype}
\case{SomeString1}{some text here}
\case{SomeString2}{some different text here}
\end{switchdoctype}
\end{document}
This gives an error: ERROR: Argument of \@secondoftwo has an extra }. I gather this is some sort of problem with using \ifdefequal. How can I make this work? I suspect it's some trick of expansion but I can't make this work with my limited knowledge of [La]TeX; I'm interested in learning something from making this work.
MacTeX 2010 here, which is based on TeX Live 2010 AFAIK. Thanks!
P.S.: boolexpr has a \switch but I can't use it because it conflicts badly with etoolbox (and BibLaTeX depends on etoolbox as far as I can tell). I have reported this incompatibility to the author listed in boolexpr's documentation.

~s? – Hendrik Vogt Nov 11 '10 at 09:19texdoc l3prgwas just bringing up expl3.pdf. I have since learned to ask forsource3which appears to be a very comprehensive reference document. I'm excited to see all this stuff, especially all the standardized names. (And ignoring spaces also seems very kind to people writing commands.) If anyone in a position to do so reads this: it might be nice to mention the existence of source3 in the expl3 document. (My PDF reader didn't find that string.) – dsedivec Nov 11 '10 at 19:23\exp_args:NVis needed before\str_case:nnF. – L.J.R. Mar 21 '22 at 12:14