I have the following problem: I am using the etoolbox package to check if a macro (say, \foo) expands to one of several possible strings (say, bar, baz, abc, or other). I need to execute different code depending on what string \foo expands to.
My current solution is
\ifdefstring{\foo}{bar}
{% if \foo is bar
<do something>
}
{% if \foo is not bar
\ifdefstring{\foo}{baz}
{% if \foo is baz
<do something else>
}
{% if \foo is not bar or baz
\ifdefstring{\foo}{abc}
{% if \foo is abc
<do something else>
}
{% if \foo is not bar, baz, or abc
<do something else>
}
}
}
Although this works, it is not satisfactory due to the deep nesting, and it doesn't generalize well to longer lists of possible strings. In my real situation, I have up to eight possible strings to check, so this solution creates unreadable code.
My question is, what alternative options (in LaTeX2e) do I have to check if a macro expands to one of several strings?
Ideally, the solution would also work for other etoolbox comparison commands (e.g., \ifstrequal). However, the solution need not use the etoolbox package.

