1

When parsing expressions, one way that I like to grab an integer delimited on the end by any nonexpandable token that is not a digit is using a count register and \afterassignment. So the code looks like:

\newcount\mycount
\def\mycommand#1{\mycommand@#1\nil}
\def\mycommand@{\afterassignment\mycommand@@\mycount=}
\def\mycommand@@#1\nil{integer: "\the\mycount", rest: "#1"}

so then \mycommand{12 and text} produces integer: "12", rest: "and text". For an example of why I would want to do this, see my answer here: https://tex.stackexchange.com/a/470171/23866. The asker wanted a command that takes as argument a specification like

column 10 to 12 row 3 to 5
column 10 row 7
row 3 to 5

Is there a sanctioned latex3 approach to this?

Hood Chatham
  • 5,467
  • Why not just use delimited arguments? \def\grab column#1to#2row#3to#4\endgrab{...} – Henri Menke Jan 15 '19 at 02:28
  • I edited it to include some cases where it the format isn't exactly the same, so that I don't know exactly what token follows the number. – Hood Chatham Jan 15 '19 at 05:05
  • 1
    The answer is going to be 'no' or at least 'not at the moment': we've not come across a place where such an interface is required. – Joseph Wright Jan 15 '19 at 09:07

0 Answers0