I am looking for a command allowing me to get 3 as output if the input is 3.2. \StrBefore{3.2}{.} works fine for this purpose but is not expandable and I need to call it in another macro inside a \setcounter command where it is expected to have a number and then to expand the \StrBefore command. Is there a work around using \StrBefore or do I need a different function and which one?
\documentclass{book}
\usepackage{xstring}
\newcounter{try}
\newcommand{\foo}[1]{\StrBefore{#1}{.}}
\newcommand\test[1]{\setcounter{try}{\foo{#1}}%
\arabic{try}}
\begin{document}
Result of foo\{3.2\}: \foo{3.2}
Result of test\{3.2\}: \test{3.2}
\end{document}
\fooexsafer by something like\newcommand{\foo}[1]{\getfirst#1..\@nil} \def\getfirst#1.#2.#3\@nil{#1}. This also works for cases like\foo{32}. – Jonathan Sep 15 '13 at 11:59#2which always contains a trailing dot in this case .... – Jonathan Sep 15 '13 at 12:44\@nilby\fooexitself, thus avoiding the\makeatletter. – Sep 15 '13 at 15:01