Changes

Jump to navigation Jump to search
441 bytes added ,  01:07, 4 August 2005
Added real examples to processing comma-separated lists.
\IHaveTo{tidy up}{Monday}
</texcode>
Will This will print out: <context>\def\IHaveTo#1#2{I have to #1 on #2.\par}\IHaveTo{tidy up on }{Monday.}</context>
But sometimes you have to repeat some task more than once. In this case you can define a new command:
\MyMumOrderedMeTo[Monday,Wednesday,Saturday]{tidy up}
</texcode>
will spare you some typing <i>(however but not some tidying up!)</i>: <context>\def\IHaveTo#1#2{I have to #1 on #2.\par}\def\MyMumOrderedMeTo[#1]#2% {\processcommalist[#1]{\IHaveTo{#2}}}\MyMumOrderedMeTo[Monday,Wednesday,Saturday]{tidy up}</context>
I have to tidy up on Monday.
I have to tidy up on Wednesday.
I have to tidy up on Saturday.
In case a command <tt>\IHaveTo</tt> is already defined in a slightly different way:
\endgroup}
</texcode>
 
This, again, produces:
 
<context>
\def\IHaveTo[#1]#2{I have to #2 on #1.\par}
\def\MyMumOrderedMeTo[#1]#2%
{\begingroup
\def\processitem##1{\IHaveTo[##1]{#2}}%
\processcommalist[#1]\processitem
\endgroup}
\MyMumOrderedMeTo[Monday,Wednesday,Saturday]{tidy up}
</context>
=== Processing a dash-separated list of values ===
Anonymous user

Navigation menu