# Comparing koma variable to string

I can't quite figure out how to compare a koma variable with a string by using \usekomavar{..}.

I want to set another koma variable depending on the value of the first. So I want something like this

\newkomavar{xyz}
\newkomavar{abc}

\setkomavar{xyz}{yes}

\ifnum\pdfstrcmp{\usekomavar{xyz}}{yes}=0
\setkomavar{abc}{yes}
\else
\setkomavar{abc}{yeah}
\fi


Any ideas?

Note that \usekomavar has a starred version and can take an optional argument. So it is not fully expandable. So it can not be used inside \pdfstrcmp or the KOMA-script command \ifstr.

I have asked Markus. The optional argument can be used for commands like \MakeUppercase which influences the contents of its argument (that is explained in the manual) but also for such a comparison.

I would use the KOMA-script command \ifstr to do the comparison:

\documentclass{scrlttr2}
\newkomavar{abc}
\newkomavar{xyz}
\setkomavar{xyz}{yes}

\begin{document}
\usekomavar[\ifstr]{xyz}{yes}
{\setkomavar{abc}{yes}}% true part
{\setkomavar{abc}{yeah}}% false part
\usekomavar{abc}

\bigskip
\usekomavar[\ifstr]{xyz}{other}
{\setkomavar{abc}{true}}% true part
{\setkomavar{abc}{false}}% false part
\textbf{\usekomavar[\MakeUppercase]{abc}}
\end{document}


Result:

But you will get same result with \ifnum\pdfstrcmp:

\documentclass{scrlttr2}
\newkomavar{abc}
\newkomavar{xyz}
\setkomavar{xyz}{yes}

\begin{document}
\usekomavar[\ifnum\pdfstrcmp]{xyz}{yes}=0
\setkomavar{abc}{yes}
\else
\setkomavar{abc}{yeah}
\fi
\usekomavar{abc}

\bigskip
\usekomavar[\ifnum\pdfstrcmp]{xyz}{other}=0
\setkomavar{abc}{true}
\else
\setkomavar{abc}{false}
\fi
\textbf{\usekomavar[\MakeUppercase]{abc}}
\end{document}