The arguments to a macro or string can be examined using a variety of escapes.
Note that the
shiftrequest can change its value.
Any individual argument can be retrieved with one of the following escapes:
Retrieve the nth, nnth or nnnth argument. As usual, the first form only accepts a single number (larger than zero), the second a two-digit number (larger or equal to 10), and the third any positive integer value (larger than zero). Macros and strings can have an unlimited number of arguments. Note that due to copy-in mode, use two backslashes on these in actual use to prevent interpolation until the macro is actually invoked.
In some cases it is convenient to use all of the arguments at once (for example, to pass the arguments along to another macro). The
\$*escape concatenates all the arguments separated by spaces. A similar escape is
\$@, which concatenates all the arguments with each surrounded by double quotes, and separated by spaces. If not in compatibility mode, the input level of double quotes is preserved (see Request and Macro Arguments).
.de foo . tm $1=`\\$1' . tm $2=`\\$2' . tm $*=`\\$*' . tm $@=`\\$@' . tm $^=`\\$^' .. .foo " This is a "test" ⇒ $1=` This is a ' ⇒ $2=`test"' ⇒ $*=` This is a test"' ⇒ $@=`" This is a " "test""' ⇒ $^=`" This is a "test"'
This escape is useful mainly for macro packages like trace.tmac which redefines some requests and macros for debugging purposes.
If a macro is called as a string (within another macro), the value of
\$0isn't changed..de foo . tm \\$0 .. .als foo bar ..de aaa . foo .. .de bbb . bar .. .de ccc \\*[foo]\\ .. .de ddd \\*[bar]\\ .. ..aaa ⇒ foo .bbb ⇒ bar .ccc ⇒ ccc .ddd ⇒ ddd
See Request and Macro Arguments.