[texhax] Can I invoke some tex command at commank like this?

Ian Collier imc at comlab.ox.ac.uk
Fri Sep 26 12:30:31 CEST 2003


redduzt at yahoo.com (Chakrit Nimmanant) writes:
>    I have an example like this:
>   "\setbox0 = \hbox{Evam}
>The box has width \the\wd0, height \the\ht0, and depth
>\the\dp0."

>    As you can see, TeX is very useful to determine
>the dimension of my "Evam". So,I want to invoke some
>TeX commands on standard input which can receive
>"Evam" as a parameter and returns a value of \wd0 to
>my standard output.

Do you mean something like this?

\catcode`\^^M=\the\catcode`\%
\loop
 \read16 to\text
 \if T\ifx\text\empty F\else T\fi
  \setbox0=\hbox{\text}
  \message{The box has width \the\wd0, height \the\ht0, and depth \the\dp0.}
 \repeat
\end

(This carries on reading until you enter an empty line, then stops.
If you don't need it to loop then you just need the \read, \setbox
and \message lines.  The \catcode line makes TeX ignore the carriage
return on the end of whatever you type.  Replace the number 16 by -1
if you don't want TeX to prompt with "\text=" before you type in the
text.)
-- 
---- Ian Collier : imc at comlab.ox.ac.uk : WWW page below
------ http://users.comlab.ox.ac.uk/ian.collier/imc.shtml


More information about the texhax mailing list