* String -> register conversion
@ 2002-02-06 8:52 Hans Hagen
2002-02-06 15:07 ` Slawek Zak
0 siblings, 1 reply; 2+ messages in thread
From: Hans Hagen @ 2002-02-06 8:52 UTC (permalink / raw)
[bounced mail, use address know to list]
>Hi,
>
>It have a probably very stupid question to ask; but so far doing math in
>TeX did
>not come in my way.
>
>How can I make the following work in Tex? :
>
>\def\mac{10}
>\newcount\cnt
>\cnt=\mac
>\the\mac
>\bye
>
>The idea is simple. I want TeX to expand \mac and make an assignment to
>register
>\cnt. I tried \expandafter\cnt=\mac, but it doesn't work. Perhaps because
>of the
>= after \cnt.
first of all, \the\mac is wrong, since \mac is no register, so that one
should be \the\cnt
but then, again you get not what you want, because tex keeps on reading
until no numbers are found, so you need to stop reading by saying
\cnt=\mac\relax (or \cnt\mac\space)
if you want a neutral way to get a number, use \number\cnt or \number\mac
since \number is less strict in what it expects
Hans
PS. Of course a google search does not work, since mac will always lead you
to big macs i suppose -)
-------------------------------------------------------------------------
Hans Hagen | PRAGMA ADE | pragma@wxs.nl
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
fall-back web server:
www.pragma-pod.nl
-------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: String -> register conversion
2002-02-06 8:52 String -> register conversion Hans Hagen
@ 2002-02-06 15:07 ` Slawek Zak
0 siblings, 0 replies; 2+ messages in thread
From: Slawek Zak @ 2002-02-06 15:07 UTC (permalink / raw)
Cc: ntg-context
On Wed, 06 Feb 2002, Hans Hagen verbalised:
> [bounced mail, use address know to list]
Fixed, thanks.
>>How can I make the following work in Tex? :
>>
>>\def\mac{10}
>>\newcount\cnt
>>\cnt=\mac
>>\the\mac
>>\bye
>>
>> The idea is simple. I want TeX to expand \mac and make an assignment to
>> register \cnt. I tried \expandafter\cnt=\mac, but it doesn't work. Perhaps
>> because of the = after \cnt.
>
> first of all, \the\mac is wrong, since \mac is no register, so that one should
> be \the\cnt
Sure. My fault. I meant \the\cnt of course.
> but then, again you get not what you want, because tex keeps on reading until
> no numbers are found, so you need to stop reading by saying \cnt=\mac\relax
> (or \cnt\mac\space)
Ouch. \relax, I should've thought of it. Thanks.
> if you want a neutral way to get a number, use \number\cnt or \number\mac
> since \number is less strict in what it expects
Yep. That reminds me to put The TeXbook lecture on my to-read list again ;)
> PS. Of course a google search does not work, since mac will always lead you to
> big macs i suppose -)
Apple would come up as the first search result on Google, actually ;)
/S
--
hundred-and-one symptoms of being an internet addict:
234. You started college as a chemistry major, and walk out four years
later as an Internet provider.
* Suavek Zak / PGP: finger://zaks@prioris.mini.pw.edu.pl
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-02-06 15:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-06 8:52 String -> register conversion Hans Hagen
2002-02-06 15:07 ` Slawek Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).