# [texhax] visibility of variables through \rput

Brandon Kuczenski brandon at 301south.net
Mon Aug 10 02:32:33 CEST 2009

Hi TeXers,

I have encountered a difficulty with using custom commands from inside
\rput.  When the commands define new macros, those macros aren't visible
from outside the \rput.  In the example below, the command defines
\theresult-- the first reference to \theresult works; the second reports
an "Undefined control sequence".  Is there any way to make the results of
the computation visible outside of the \rput scope?

\documentclass{article}
\usepackage{fp}

\newcommand{\compute}[2]{%
\FPmul\theresult{#1}{#2}
\theresult
}

\begin{document}
\begin{pspicture}(0,0)(5,5)

\rput(2,2){\compute{0.4}{0.377}
\rput(10,0){\theresult} % this one works fine
}

\rput(10,5){\theresult}  % this one gives an error

\end{pspicture}
\end{document}