This should be easy, but I don't understand why the test below fails... I expected Hurrah! to be printed when the \currentchar
count reaches 90 (i.e. the character code of Z
).
There must be some expansion problem somewhere, but I believe I use \expandafter
as is necessary, here. What am I doing wrong? Should I take a different approach?
\def\mysteryletter{Z}
% loop through A-Z to find out the mystery letter
\newcount\currentchar
\currentchar=65 % <-- charcode of A
\loop
\edef\temp{\char\currentchar}
\temp
\expandafter\expandafter\expandafter\ifx\expandafter\mysteryletter\temp Hurrah!\fi
\advance \currentchar by 1
\unless\ifnum \currentchar>90
\repeat
\bye