# Weird problem with \TextField in a form

I have the following code defined in a class file I am writing:

\newlength{\textfieldlength}\newlength{\labellength}\newlength{\testlength}

\newcommand{\textfieldintable}[3]{
\setlength{\textfieldlength}{\linewidth}
\settowidth{\labellength}{#1}
\setlength{\testlength}{350pt}

\typeout{\the\labellength}
\typeout{\the\textfieldlength}
\textbf{#1} &
\TextField[name=#1,charsize=8pt,bordercolor={1 1 1}, height=12pt, width=360pt,value=#2]{#3}
}


When I use this new command in an external file:

\begin{Form}

\begin{tabular}{ll}
\end{tabular}

\end{Form}


I get a form field that one can type in, in the second column (in addition to the label in the first column).

However, if I change the code above to:

\TextField[name=#1,charsize=8pt,bordercolor={1 1 1}, height=12pt, width=\the\textfieldlength,value=#2]{#3}


the form field vanishes. The first column of the table still gets the #1 argument as it should. The same thing happens if I use \textfieldlength, \the\labellength, \labellength, or \testlength instead of \the\textfieldlength.

What is going on? Why can't I use a variable as the value for width= key in \TextField?

-
Please add what's necessary to make the code a compilable example. –  egreg May 1 at 16:05