🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #11090

re: question about parsing numbers

#11090
From: bbeeton
Date: Sat, 09 Jan 1993 18:21
30 lines
1777 bytes
julio dix (jd01@swtexas.bitnet, to comp.text.tex, jan 8) wants
to strip off the first digit from a series of digits in a box,
replacing the remaining digits into the same box.

i won't tackle the boxing part of the question, but can explain
why the whole string of numbers is being gobbled at once.

take a simpler example:
    \newcount\num
    \def\newnum#1#2.{\num=#1 \def\rest{#2}}
    \newnum12345.
this will end up with \num=12345 and \rest empty (with a delimited
string, the part between delimiters need not contain anything).

reason?  a counter is expecting an integer value.  12345 is just as
much an integer as 1, so parsing of the argument continues until a
non-digit is encountered.  this can also have some surprising effects
when a numeric value is the last thing in the expansion of a
definition and data following that control sequence in a file is
also numeric.  (a warning in tugboat 5#1, p.48, covered this in more
detail, but that was a long time ago, and maybe it's time to
reiterate.)

if num is treated as a token string or an ordinary control sequence,
this approach will work.  if it's really necessary to set a counter
to the value of the first digit, do it in two steps:
    \newcount\num
    \def\newnum#1#2.{\def\xnum{#1}\num=\xnum \def\rest{#2}}
    \newnum12345.
						-- bb
Technical Details
Message-ID: <726603701.528921.BNB@MATH.AMS.ORG>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!jvnc.net!newsserver.jvnc.net!rutgers!att-out!pacbell.com!network.ucsd.edu!mvb.saic.com!info-tex

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!jvnc.net!newsserver.jvnc.net!rutgers!att-out!pacbell.com!network.ucsd.edu!mvb.saic.com!info-tex
From: BNB@MATH.AMS.ORG (bbeeton)
Newsgroups: comp.text.tex
Subject: re: question about parsing numbers
Message-ID: <726603701.528921.BNB@MATH.AMS.ORG>
Date: 9 Jan 93 18:21:41 GMT
Organization: Info-Tex<==>Comp.Text.Tex Gateway
Lines: 30
X-Gateway-Source-Info: Mailing List