Mojca Miklavec wrote:
Taco Hoekwater wrote:

Mojca Miklavec wrote:

I would like to define a command, which would be called in the following way:
   \TheBossWantsTheWorkToBeDoneOn[monday,wednesday,thursday]{tidy up}

so that it would be equivalent to:
   \WeHaveToDo[monday]{tidy up}
   \WeHaveToDo[wednesday]{tidy up}
   \WeHaveToDo[thursday]{tidy up}

I played a bit with different variants of \processcommalist, but I
can't figure out how to use it in this particular case.

The trick is to store the tidy up inside the processing command,
like so:

  \def\WeHaveToDo[#1]#2{\message{(#1: #2)}}

  \def\TheBossWantsTheWorkToBeDoneOn[#1]#2%
    {\begingroup
     \def\processitem##1{\WeHaveToDo[##1]{#2}}%
     \processcommalist[#1]\processitem
     \endgroup }

  \TheBossWantsTheWorkToBeDoneOn[monday,wednesday,thursday]{tidy up}


Great, thanks Taco! It works. It seems easier than I thought, but I
could have spent hours looking for the proper solution alone.

Actually, there is an easier way to do this; just swap the arguments to 
WeHaveToDo:

\def\TheBossWantsTheWorkToBeDoneOn[#1]#2%
  {\processcommalist[#1]{\WeHaveToDo{#2}}}

\def\WeHaveToDo#1#2{(#2: #1)}

\starttext

\TheBossWantsTheWorkToBeDoneOn[monday,wednesday,thursday]{tidy up}

\stoptext

btw, nice thread for a wiki entry

I hope this will land in the t-rsteps module (\OnSteps[1,2,3,6]{...}).


Is there also a possibility to define a command like
   \IHaveToDoTheTasks[1-4,7,9-11]{until tomorrow}

There was not, but knowing Hans I trust that soon there will be :-).

hm, well, it does rain outside, but ...

Hans

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

Reply via email to