How can I make the \ifcase
statement accept my \myindex
macro as an argument in the following example. On its own, the \myindex
macro expands correctly, however, I get an error when I use it as the argument to the \ifcase
statement.
\documentclass{article}
\usepackage{xstring,ifthen}
\newcommand{\id}{32103210}
\newcommand{\mycommand}[1]{
\def\myindex{\StrChar{\id}{#1}} %get the #1th character from \id
My index is \myindex\\% <-- this works fine
\ifcase\myindex% <---- ifcase not working with \myindex but works with other macros
zero \or one \or two \or three% <--- expecting zero
\fi
}
\begin{document}
\mycommand{4}
\end{document}