There are some code. I strip out unrelated parts and get test one:
\documentclass[a4paper,11pt]{extarticle}
\begin{document}
\newcommand{\mystrA}{%
a%
\or b%
\or c%
\else d%
}
\newcommand{\mystrB}{%
e%
\or f%
\else g%
}
\newcommand{\mystr}{\mystrA}
\newcounter{str}
\newcommand{\usestr}{%
\ifcase\value{str}\mystr\fi%
\addtocounter{str}{1}%
}
\usestr,\usestr,\usestr,\usestr,\usestr
\end{document}
and after compilation with pdflatex I get:
But I was expecting to get "a,b,c,d," as result…
So question. What is going wrong?
Why \ifcase provide nothing for values of counter more than zero?
And how right rewrite the code to get I expected?
Best Answer
So TeX expands
\value
to get a number to test with\ifcase
if that is >0 it skips ahead not expanding to find a matching\or
or\fi
and finds the\fi
so the expansion of is empty.I would use