I am trying to do what I though was fairly simple - use an xargs defined macro in a CS. MWE:
\documentclass{article}
\usepackage{xargs}
\usepackage{etoolbox}
\makeatletter
\def\abx@foo@baz@bar{test}
\def\abx@field@original@default@test{baz}
\newcommandx*{\blx@imc@thefield}[3][1=original,2=default]{\csuse{abx@field@#1@#2@#3}}
\def\blx@getformat#1#2{%
\ifcsundef{abx@#1@\blx@imc@thefield{test}@#2}
{no}
{yes}}
\begin{document}
\blx@getformat{foo}{bar}
\makeatother
\end{document}
For me, this always gives:
! Missing \endcsname inserted.
<to be read again>
\begingroup
l.17 \blx@getformat{foo}{bar}
I cannot for the life of me work out why. Running it through tracing, it dies in an internal xargs macro. The \abx@field@original@default@test macro works fine on its own, it just doesn't like being in the \ifcsundef test. If I replace the xargs \newcommandx with a plain \def (without optional args, of course), it works. I've tried protecting the newcommandx call, tried passing optional args with defaults to the macro etc. but always get the same error. Any ideas much appreciated.