I am trying to populate a list of variables (in the attached example starting with \@addressone
) with the values obtained from a set of commands. The first variable will get the first of whatever values I have, the second the second, etc. until values run out and from then on all the variables shall be empty. I am trying to do this with nested if statements:
\def \mystreet#1{\def\@mystreet{#1}} % Defines the \name command to set name
\def \mycity#1{\def\@mycity{#1}} % Defines the \name command to set name
\def \myphone#1{\def\@myphone{#1}} % Defines the \name command to set name
\def \myemail#1{\def\@myemail{#1}} % Defines the \name command to set name
\def \myurl#1{\def\@myurl{#1}} % Defines the \name command to set name
\let \@mystreet \relax
\let \@mycity \relax
\let \@myphone \relax
\let \@myemail \relax
\let \@myurl \relax
\ifdefined\@mystreet
\def \@addressone {\@mystreet}
\else
\ifdefined\@mycity
\def \@addressone {\@mycity}
\else
\ifdefined\@myphone
\def \@addressone {\@myphone}
\else
\ifdefined\@myemail
\def \@addressone {\@myemail}
\else
\ifdefined\@myurl
\def \@addressone {\@myurl}
\else
\def \@addressone {}
\fi
\fi
\fi
\fi
\fi
All of this seems to be ignored beyond the first if statement. If \@mystreet
is undefined \@addressone
will be empty, even if say \@mycity
is defined.
COMMENT: it turns out my issue had nothing to do with the nested \ifdefined
statements (which work just as you would expect them to) but rather with how and when LaTeX decided that my user input from files using this class counts as having defined the variables.
Best Answer
The main error is that
\relax
isn't undefined. This test file is complete and can be run through latex, the terminal output iswhich is (I think) what you want in each of the three cases.