I am trying to check if a variable is defined without using extra packages (since I want ot use it in an .lco file) and if it is defined then check if it is empty.
The definition check works but the check for empty content does not work:
\documentclass{scrlttr2}
\newcommand{\stampfile}{}
\begin{document}
\ifdefined\stampfile
\ifx\stampfile\empty
\textbackslash stampfile is empty
\else
\textbackslash stampfile is not empty
\fi
\else
\textbackslash stampfile is not defined
\fi
\end{document}
I has a look at How to check if a macro value is empty or will not create text with plain TeX conditionals? but the solutions did work either...
E.g. I tried:
\documentclass{scrlttr2}
\newcommand{\stampfile}{}
\newcommand{\checkempty}[1]{
\if\relax\detokenize{#1}\relax
EMPTY%
\else
NON EMPTY%
\fi
}
\begin{document}
\ifdefined\stampfile
\ifx\stampfile\empty
\textbackslash stampfile is empty
\else
\textbackslash stampfile is not empty
\fi
\else
\textbackslash stampfile is not defined
\fi
\checkempty{\stampfile}
\end{document}
\tlifblankTFdoes work. Also the hint with*is very helpful. Thanks!Can you point me into a direction of good reading material to learn how the parts between the\ExplSyntaxOnworks? I have seen these in solutions a few times but never really understood them to use them myself. I do know Python, C++ and a few other languages... – mrCarnivore Apr 21 '23 at 10:08texdoc interface3– Frank Mittelbach Apr 22 '23 at 07:56