My MWE was created with the help of these two Q&As: 1 and 2.
MWE:
\documentclass{article}
\usepackage{xparse}
\usepackage{xstring}
\usepackage{pdftexcmds}
% Command declaring a global definition if argument not empty, and using a pre-defined empty definition if argument empty
\ExplSyntaxOn%
\NewDocumentCommand{\Client}{g}%
{%
\IfNoValueTF{#1}%
{%
\tl_use:N \g_jalep_client_tl%
}%
{%
\tl_gset:Nn \g_jalep_client_tl {#1}%
}%
}%
\tl_new:N \g_jalep_client_tl%
\ExplSyntaxOff%
% Attempt using \pdfstrcmp
\makeatletter
\newcommand\foo[1]{%
\ifnum\pdf@strcmp{\unexpanded{#1}}{Adam}=0 %
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
{Adam}
{Eve}%
}
\makeatother
\begin{document}
\Client{Adam}
% Attempt using xstring
\par My client should be Adam: \IfSubStr{Adam}{\Client}{Adam}{Eve}
% Attempt using \pdfstrcmp
\par My client should be Adam: \foo{\Client}
\end{document}
Output:
Notes:
- The
\IfSubStrand\fooline work when there exists something like:\newcommand{\Client}{Adam}or\newcommand{\Client}{Eve}or\newcommand{\Client}{Anything}. - From this, I'm inclined to believe
\Clientproduces something other than a string? How do I change this/convert this/work with this when I'm trying to create an if-else statement?
Question:
How do I make a string comparison with the \NewDocumentCommand shown in my MWE? Something like: If \Client = Adam, then print: Adam, else print: Eve


\Client? – Werner Jan 16 '19 at 01:01\Clientis always called either empty like this:\Client{}or with any argument like this:\Client{Argument}. 2.\Client{}or\Client{Argument}should print nothing, and only the command\Clientshould print whatever the global definition defined with\Clientis – jed Jan 16 '19 at 02:05\Client{<name>}destroys its and just stores the<name>. – Werner Jan 16 '19 at 02:35