I would like to write a macro getlengthin to get a length or dimen as floating point number in a specified unit. Here is what I have created so far:
\documentclass{article}
\usepackage[nomessages]{fp}
\newcount\lengthcount
\newcount\unitcount
\def\getlengthin#1#2{%
\lengthcount=#1%
\unitcount=\dimexpr1#2%
\FPdiv\result{\the\lengthcount}{\the\unitcount}%
\result%
}
\def\a{\getlengthin{\paperwidth}{mm}} % \edef does not work here !
\begin{document}
\a
\getlengthin{\paperwidth}{mm}
\getlengthin{\textheight}{mm}
\end{document}
For some reason I need to calculate the length in the preamble and I tried to use edef, but edef does not work with my macro. What is the problem here?
