I am trying to simply set the value of the counter try which I defined previously to the value of the output of the \foo command. However this does not work. I guess that the problem is coming from the fact that in the \test macro the \foo one is not expanded at the right time of compilation. Since I know really few concerning macros and their expansion I am not able to find the solution here.
\documentclass{book}
\usepackage{ifthen}
\newcounter{try}
\newcommand{\foo}[1]{\ifthenelse{#1=1}{1}{0}}
\newcommand\test[1]{\setcounter{try}{\foo{#1}}%
\arabic{try}}
\begin{document}
Result of foo\{3\}: \foo{3}
Result of test\{3\}: \test{3}
\end{document}


\foois defined as\newcommand{\foo}[1]{\StrBefore{#1}{.}}using thexstringpackage? – Ludovic C. Sep 15 '13 at 11:13\StrBeforedoesn't expandably produce its result. Maybe you want to make another question better specifying your context and the expected values to argument#1. – egreg Sep 15 '13 at 11:16