I am trying to define a macro
\formatstr{\mystring}{(string empty)}{the string is: #1}
which expands to (string empty) when \mystring is empty (as judged, e.g. by etoolbox's \csdefempty) and expands to the string is: \mystring otherwise.
I could write, for example,
\newcommand*\formatstr[3]{%
\def\fmt##1{#3}%
\ifdefempty#1{#2}{\fmt{#1}}%
}
which works as I want, except for the fact that \formatstr itself is not expandable because of the \def assignment.
Is there any other way in which I could substitute the #1 in the third argument of \formatstr with \mystring in an expandable way?
Edit: Let me try to more clearly explain what I'm trying to do
Using etoolbox I can type things such as
\ifdefempty{\mystring}{(empty string)}{the string \mystring\ is funny}
But this gets tedious if I have to write
\ifdefempty{\mystringwithaverylongname}{(empty string)}{the string \mystringwithaverylongname\ is long}
So what I would like to be able to write is
\formatstr{\mystringwithaverylongname}{(empty string)}{some string #1 is nice}
Or perhaps
\formatstr{\mystringwithaverylongname}{(empty string)}{i've heard that :str is interesting}
What I want to know if is it possible to substitute the #1 (or :str) in the third argument with the contents coming from the first?

\ifx#1\@empty? – Joseph Wright♦ Jul 25 '12 at 16:16\def! – Juan A. Navarro Jul 25 '12 at 16:19\defat all. If you want to use\ifdefempty, why not just\ifdefempty{#1}...? – Joseph Wright♦ Jul 25 '12 at 16:24the string is: #1withthe string is: \mystring. – Juan A. Navarro Jul 25 '12 at 16:25