I'd like to test whether \solflag is defined or whether \profflag is defined. I'd like to do so with a macro whose argument could be either "sol" or "prof" (or some other word).
My "minimal (non)working example" attempt at this is
\documentclass{article}
\RequirePackage{ifthen}
\newcommand{\solflag}{}
\newcommand{\mytest}[1]
{\ifthenelse{\isundefined{\#1flag}} {UNDEFINED}{DEFINED}}
\begin{document}
Sol test: \mytest{sol}
Bar test: \mytest{bar}
2nd bar test: \ifthenelse{\isundefined{\barflag}} {UNDEFINED}{DEFINED}
\end{document}
The result, however, is this:
Sol test: DEFINED
Bar test: DEFINED
2nd bar test: UNDEFINED
My guess is that the first "Bar" test is checking whether \bar is defined, i.e., that the concatenation of \#1 and flag in the macro just isn't happening or something.
I suspect that the answer I need is somewhere in the LaTeX-Fu of this answer, but I simply cannot make head or tail of that.
Is it possible to do what I'm hoping to do?


\mytestdouesn't use#1at all so it does not use its argument – David Carlisle Sep 23 '16 at 19:16#1, but with the improper syntax\#1flag. To the OP, the proper way to convey\#1flagis\csname #1flag\endcsname. The sequence\#1flaggets expanded as#1flagwhere#is literally the pound sign. – Steven B. Segletes Sep 23 '16 at 19:28#1would be a reference to an argument\#is an instruction to typeset a#(a pound sign is £ :-) it does not expand to a#(it doesn't expand at all actually, it's a chardef token) – David Carlisle Sep 23 '16 at 20:11\#1flagwould work. – Steven B. Segletes Sep 23 '16 at 20:18#=American "pound". I'm so...'80's. What do the youngsters call it now??? "Hashtag"! "HASHTAG!!" – Steven B. Segletes Sep 24 '16 at 04:21