I apologize if this is too newbie or a duplicate, but I've banged my head against it long enough, and searched without success. :(
I am trying to use an \if to test for an empty string without success and have traced it to my understanding of the \if itself. I have added sample code showing how I'm misusing \if in a real simple way:
\def\tmpOne{hello}
\tmpOne %shows that \tmpOne produces hello
\if{\tmpOne}{hello}
goodbye %This is never reached.
\fi
Closer to my actual application is:
\newcount\tmpInd
\def\funcOne{%
\advance\tmpInd by 1
\if{\testEmpty{\readHistory{\value\tmpInd}}}{<NOT EMPTY>}
\funcOne
\fi
}
%where \testEmpty returns either <EMPTY> or <NOT EMPTY>
%and \readHistory is my own previously defined function
%(They work as expected outside of this context)
Any help for my obviously weak understanding would be appreciated. :)
Edit: Due to information in one of the comments, I have added some extra details of my particular use case...
The definition for \testEmpty is:
\newcommand{\testEmpty}[1]{\setbox0=\hbox{#1}\ifdim\wd0=0pt<EMPTY>\else<NOT EMPTY>\fi}
The definition for \readHistory is:
\newcommand{\readHistory}[1]{\getdata[#1]\myChangeHistory}
The definition for \getData is:
\def\getdata[#1]#2{\csname data:\string#2:#1\endcsname}
The data is stored with \storeData:
\def\storedata#1#2{\tmpnum=0 \edef\tmp{\string#1}\storedataA#2\end\expandafter\def\csname data:\tmp:0\endcsname{\tmpcnt}}
\def\storedataA#1{\advance\tmpnum by1
\ifx\end#1\else
\expandafter\def\csname data:\tmp:\the\tmpnum\endcsname{#1}%
\expandafter\storedataA\fi
}
Note: I have patched these together by trawling the internet, and only partly understand them (but they all do what I want).