ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Understanding the basics of \define
@ 2013-12-10 11:23 Pavel Stupin
  2013-12-10 13:42 ` Wolfgang Schuster
  0 siblings, 1 reply; 11+ messages in thread
From: Pavel Stupin @ 2013-12-10 11:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hello:

I'm struggling with understanding the way \define is supposed to work.
I would like to have a macros to generate tables and populate them
with some specific data submitted as arguments. I apologize for my
lack of understanding of the very basics, but e.g. the following code
just doesn't compile:

\define[1]\mytable{
\startxtable
\startxrow
\startxcell #1 \stopxcell
\stopxrow
\stopxtable}

\mytable{abc}


I would appreciate your help and maybe some references to read (if
any) in order to educate myself.
Kind regards, Pavel.
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Understanding the basics of \define
  2013-12-10 11:23 Understanding the basics of \define Pavel Stupin
@ 2013-12-10 13:42 ` Wolfgang Schuster
  2013-12-10 14:24   ` Pavel Stupin
  0 siblings, 1 reply; 11+ messages in thread
From: Wolfgang Schuster @ 2013-12-10 13:42 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 10.12.2013 um 12:23 schrieb Pavel Stupin <stupin.pavel@gmail.com>:

> Hello:
> 
> I'm struggling with understanding the way \define is supposed to work.
> I would like to have a macros to generate tables and populate them
> with some specific data submitted as arguments. I apologize for my
> lack of understanding of the very basics, but e.g. the following code
> just doesn't compile:
> 
> \define[1]\mytable{
> \startxtable
> \startxrow
> \startxcell #1 \stopxcell
> \stopxrow
> \stopxtable}
> 
> \mytable{abc}
> 
> 
> I would appreciate your help and maybe some references to read (if
> any) in order to educate myself.

The problem in your example isn’t define but the stable which uses a buffer
to collect the content and buffers and be used in \def or \define commands.

What you can do in this case is to replace \startxtable with \startembeddedxtable
and change your code to

\dfeine[1]\mytable
  {\startembeddedxtable
     \startxrow
       \startxcell#1\stopxcell
     \stopxrow
   \stopembeddedxtable}

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Understanding the basics of \define
  2013-12-10 13:42 ` Wolfgang Schuster
@ 2013-12-10 14:24   ` Pavel Stupin
  2013-12-10 15:17     ` Pavel Stupin
  2013-12-10 15:57     ` Wolfgang Schuster
  0 siblings, 2 replies; 11+ messages in thread
From: Pavel Stupin @ 2013-12-10 14:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Thank you, Wolfgang!  Much to my delight, \startembeddedxtable works
indeed, however, when I increase the number of arguments up to 10
--- to use the simplest example possible, without any tables:
\define[10]\myText{#1 #2 #3 #4 #5 #6 #7 #8 #9 #10} --- it doesn't work
again (works fine with 9 arguments). Am I correct assuming that
there's an inherent limitation to 9 arguments only or the 2+-digit
numbers should be written somehow differently? Is there any
workaround?

Kind regards, Pavel.

2013/12/10 Wolfgang Schuster <schuster.wolfgang@gmail.com>:
>
> Am 10.12.2013 um 12:23 schrieb Pavel Stupin <stupin.pavel@gmail.com>:
>
>> Hello:
>>
>> I'm struggling with understanding the way \define is supposed to work.
>> I would like to have a macros to generate tables and populate them
>> with some specific data submitted as arguments. I apologize for my
>> lack of understanding of the very basics, but e.g. the following code
>> just doesn't compile:
>>
>> \define[1]\mytable{
>> \startxtable
>> \startxrow
>> \startxcell #1 \stopxcell
>> \stopxrow
>> \stopxtable}
>>
>> \mytable{abc}
>>
>>
>> I would appreciate your help and maybe some references to read (if
>> any) in order to educate myself.
>
> The problem in your example isn’t define but the stable which uses a buffer
> to collect the content and buffers and be used in \def or \define commands.
>
> What you can do in this case is to replace \startxtable with \startembeddedxtable
> and change your code to
>
> \dfeine[1]\mytable
>   {\startembeddedxtable
>      \startxrow
>        \startxcell#1\stopxcell
>      \stopxrow
>    \stopembeddedxtable}
>
> Wolfgang
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Understanding the basics of \define
  2013-12-10 14:24   ` Pavel Stupin
@ 2013-12-10 15:17     ` Pavel Stupin
  2013-12-10 15:29       ` Pavel Stupin
  2013-12-10 15:57     ` Wolfgang Schuster
  1 sibling, 1 reply; 11+ messages in thread
From: Pavel Stupin @ 2013-12-10 15:17 UTC (permalink / raw)
  To: mailing list for ConTeXt users

To answer my own question. I think I've solved the problem by
splitting a macros into several ones and then nesting them into each
opther. A sort of a clumsy solution but it works. Kind regards, Pavel.

2013/12/10 Pavel Stupin <stupin.pavel@gmail.com>:
> Thank you, Wolfgang!  Much to my delight, \startembeddedxtable works
> indeed, however, when I increase the number of arguments up to 10
> --- to use the simplest example possible, without any tables:
> \define[10]\myText{#1 #2 #3 #4 #5 #6 #7 #8 #9 #10} --- it doesn't work
> again (works fine with 9 arguments). Am I correct assuming that
> there's an inherent limitation to 9 arguments only or the 2+-digit
> numbers should be written somehow differently? Is there any
> workaround?
>
> Kind regards, Pavel.
>
> 2013/12/10 Wolfgang Schuster <schuster.wolfgang@gmail.com>:
>>
>> Am 10.12.2013 um 12:23 schrieb Pavel Stupin <stupin.pavel@gmail.com>:
>>
>>> Hello:
>>>
>>> I'm struggling with understanding the way \define is supposed to work.
>>> I would like to have a macros to generate tables and populate them
>>> with some specific data submitted as arguments. I apologize for my
>>> lack of understanding of the very basics, but e.g. the following code
>>> just doesn't compile:
>>>
>>> \define[1]\mytable{
>>> \startxtable
>>> \startxrow
>>> \startxcell #1 \stopxcell
>>> \stopxrow
>>> \stopxtable}
>>>
>>> \mytable{abc}
>>>
>>>
>>> I would appreciate your help and maybe some references to read (if
>>> any) in order to educate myself.
>>
>> The problem in your example isn’t define but the stable which uses a buffer
>> to collect the content and buffers and be used in \def or \define commands.
>>
>> What you can do in this case is to replace \startxtable with \startembeddedxtable
>> and change your code to
>>
>> \dfeine[1]\mytable
>>   {\startembeddedxtable
>>      \startxrow
>>        \startxcell#1\stopxcell
>>      \stopxrow
>>    \stopembeddedxtable}
>>
>> Wolfgang
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to the Wiki!
>>
>> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
>> archive  : http://foundry.supelec.fr/projects/contextrev/
>> wiki     : http://contextgarden.net
>> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Understanding the basics of \define
  2013-12-10 15:17     ` Pavel Stupin
@ 2013-12-10 15:29       ` Pavel Stupin
  2013-12-10 16:54         ` Alan Braslau
  0 siblings, 1 reply; 11+ messages in thread
From: Pavel Stupin @ 2013-12-10 15:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users

..Alas, I was too hasty to congratulate myself as it obviously doesn't
work as intended (the arguments in the nested function get hard-coded
and are of no use). :) So I'm still looking forward for ConTeXt
masters to enlighten me.

Kind regards, Pavel.

2013/12/11 Pavel Stupin <stupin.pavel@gmail.com>:
> To answer my own question. I think I've solved the problem by
> splitting a macros into several ones and then nesting them into each
> opther. A sort of a clumsy solution but it works. Kind regards, Pavel.
>
> 2013/12/10 Pavel Stupin <stupin.pavel@gmail.com>:
>> Thank you, Wolfgang!  Much to my delight, \startembeddedxtable works
>> indeed, however, when I increase the number of arguments up to 10
>> --- to use the simplest example possible, without any tables:
>> \define[10]\myText{#1 #2 #3 #4 #5 #6 #7 #8 #9 #10} --- it doesn't work
>> again (works fine with 9 arguments). Am I correct assuming that
>> there's an inherent limitation to 9 arguments only or the 2+-digit
>> numbers should be written somehow differently? Is there any
>> workaround?
>>
>> Kind regards, Pavel.
>>
>> 2013/12/10 Wolfgang Schuster <schuster.wolfgang@gmail.com>:
>>>
>>> Am 10.12.2013 um 12:23 schrieb Pavel Stupin <stupin.pavel@gmail.com>:
>>>
>>>> Hello:
>>>>
>>>> I'm struggling with understanding the way \define is supposed to work.
>>>> I would like to have a macros to generate tables and populate them
>>>> with some specific data submitted as arguments. I apologize for my
>>>> lack of understanding of the very basics, but e.g. the following code
>>>> just doesn't compile:
>>>>
>>>> \define[1]\mytable{
>>>> \startxtable
>>>> \startxrow
>>>> \startxcell #1 \stopxcell
>>>> \stopxrow
>>>> \stopxtable}
>>>>
>>>> \mytable{abc}
>>>>
>>>>
>>>> I would appreciate your help and maybe some references to read (if
>>>> any) in order to educate myself.
>>>
>>> The problem in your example isn’t define but the stable which uses a buffer
>>> to collect the content and buffers and be used in \def or \define commands.
>>>
>>> What you can do in this case is to replace \startxtable with \startembeddedxtable
>>> and change your code to
>>>
>>> \dfeine[1]\mytable
>>>   {\startembeddedxtable
>>>      \startxrow
>>>        \startxcell#1\stopxcell
>>>      \stopxrow
>>>    \stopembeddedxtable}
>>>
>>> Wolfgang
>>> ___________________________________________________________________________________
>>> If your question is of interest to others as well, please add an entry to the Wiki!
>>>
>>> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>>> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
>>> archive  : http://foundry.supelec.fr/projects/contextrev/
>>> wiki     : http://contextgarden.net
>>> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Understanding the basics of \define
  2013-12-10 14:24   ` Pavel Stupin
  2013-12-10 15:17     ` Pavel Stupin
@ 2013-12-10 15:57     ` Wolfgang Schuster
  2013-12-10 21:03       ` Peter Münster
  1 sibling, 1 reply; 11+ messages in thread
From: Wolfgang Schuster @ 2013-12-10 15:57 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 10.12.2013 um 15:24 schrieb Pavel Stupin <stupin.pavel@gmail.com>:

> Thank you, Wolfgang!  Much to my delight, \startembeddedxtable works
> indeed, however, when I increase the number of arguments up to 10
> --- to use the simplest example possible, without any tables:
> \define[10]\myText{#1 #2 #3 #4 #5 #6 #7 #8 #9 #10} --- it doesn't work
> again (works fine with 9 arguments). Am I correct assuming that
> there's an inherent limitation to 9 arguments only or the 2+-digit
> numbers should be written somehow differently? Is there any
> workaround?

Yes, there is a limit of nine argument for macros. There are a few ways to extend
the number of arguments and it requires a few lines of code to do this and a better
solution is to use a key-val-interface when you have to set a lot of values.


One way to set values is the \getparameters command but the disadvantage
of this is that you to ensure not to call values (e.g. \testthree) which aren’t set
(e.g. not “three={…}” setting for the \test command).

\def\test
  {\dosingleargument\dotest}

\def\dotest[#1]%
  {\begingroup
   \getrawparameters[test][#1]%
   \starttabulate
   \NC 1 \EQ \testone \NC\NR
   \NC 2 \EQ \testtwo \NC\NR
   \stoptabulate
   \endgroup}

\starttext
\test[one={First row},two={Second row}]
\stoptext


You can avoid this problem with unknown keys when you use \getdummyparameters
to set the parameters and access them with \dummyparameter because when
you access the unknown values a empty string is returned.

\def\test
  {\dosingleargument\dotest}

\def\dotest[#1]%
  {\begingroup
   \getdummyparameters[#1]%
   \starttabulate
   \NC 1 \EQ \dummyparameter{one} \NC\NR
   \NC 2 \EQ \dummyparameter{two} \NC\NR
   \stoptabulate
   \endgroup}

\starttext
\test[one={First row},two={Second row}]
\stoptext

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Understanding the basics of \define
  2013-12-10 15:29       ` Pavel Stupin
@ 2013-12-10 16:54         ` Alan Braslau
  2013-12-10 18:11           ` Wolfgang Schuster
  0 siblings, 1 reply; 11+ messages in thread
From: Alan Braslau @ 2013-12-10 16:54 UTC (permalink / raw)
  To: stupin.pavel; +Cc: mailing list for ConTeXt users

Perhaps you might want to do something processing a comma separated
list:

http://wiki.contextgarden.net/System_Macros/Comma_Separated_Lists

Alan

On Wed, 11 Dec 2013 00:29:07 +0900
Pavel Stupin <stupin.pavel@gmail.com> wrote:

> ..Alas, I was too hasty to congratulate myself as it obviously doesn't
> work as intended (the arguments in the nested function get hard-coded
> and are of no use). :) So I'm still looking forward for ConTeXt
> masters to enlighten me.
> 
> Kind regards, Pavel.
> 
> 2013/12/11 Pavel Stupin <stupin.pavel@gmail.com>:
> > To answer my own question. I think I've solved the problem by
> > splitting a macros into several ones and then nesting them into each
> > opther. A sort of a clumsy solution but it works. Kind regards,
> > Pavel.
> >
> > 2013/12/10 Pavel Stupin <stupin.pavel@gmail.com>:
> >> Thank you, Wolfgang!  Much to my delight, \startembeddedxtable
> >> works indeed, however, when I increase the number of arguments up
> >> to 10 --- to use the simplest example possible, without any tables:
> >> \define[10]\myText{#1 #2 #3 #4 #5 #6 #7 #8 #9 #10} --- it doesn't
> >> work again (works fine with 9 arguments). Am I correct assuming
> >> that there's an inherent limitation to 9 arguments only or the
> >> 2+-digit numbers should be written somehow differently? Is there
> >> any workaround?
> >>
> >> Kind regards, Pavel.
> >>
> >> 2013/12/10 Wolfgang Schuster <schuster.wolfgang@gmail.com>:
> >>>
> >>> Am 10.12.2013 um 12:23 schrieb Pavel Stupin
> >>> <stupin.pavel@gmail.com>:
> >>>
> >>>> Hello:
> >>>>
> >>>> I'm struggling with understanding the way \define is supposed to
> >>>> work. I would like to have a macros to generate tables and
> >>>> populate them with some specific data submitted as arguments. I
> >>>> apologize for my lack of understanding of the very basics, but
> >>>> e.g. the following code just doesn't compile:
> >>>>
> >>>> \define[1]\mytable{
> >>>> \startxtable
> >>>> \startxrow
> >>>> \startxcell #1 \stopxcell
> >>>> \stopxrow
> >>>> \stopxtable}
> >>>>
> >>>> \mytable{abc}
> >>>>
> >>>>
> >>>> I would appreciate your help and maybe some references to read
> >>>> (if any) in order to educate myself.
> >>>
> >>> The problem in your example isn’t define but the stable which
> >>> uses a buffer to collect the content and buffers and be used in
> >>> \def or \define commands.
> >>>
> >>> What you can do in this case is to replace \startxtable with
> >>> \startembeddedxtable and change your code to
> >>>
> >>> \dfeine[1]\mytable
> >>>   {\startembeddedxtable
> >>>      \startxrow
> >>>        \startxcell#1\stopxcell
> >>>      \stopxrow
> >>>    \stopembeddedxtable}
> >>>
> >>> Wolfgang
> >>> ___________________________________________________________________________________
> >>> If your question is of interest to others as well, please add an
> >>> entry to the Wiki!
> >>>
> >>> maillist : ntg-context@ntg.nl /
> >>> http://www.ntg.nl/mailman/listinfo/ntg-context webpage  :
> >>> http://www.pragma-ade.nl / http://tex.aanhet.net archive  :
> >>> http://foundry.supelec.fr/projects/contextrev/ wiki     :
> >>> http://contextgarden.net
> >>> ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an
> entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context webpage  :
> http://www.pragma-ade.nl / http://tex.aanhet.net archive  :
> http://foundry.supelec.fr/projects/contextrev/ wiki     :
> http://contextgarden.net
> ___________________________________________________________________________________


-- 
Alan Braslau
CEA DSM-IRAMIS-SPEC
CNRS URA 2464
Orme des Merisiers
91191 Gif-sur-Yvette cedex FRANCE
tel: +33 1 69 08 73 15
fax: +33 1 69 08 87 86
mailto:alan.braslau@cea.fr
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Understanding the basics of \define
  2013-12-10 16:54         ` Alan Braslau
@ 2013-12-10 18:11           ` Wolfgang Schuster
  2013-12-11 12:31             ` Pavel Stupin
  0 siblings, 1 reply; 11+ messages in thread
From: Wolfgang Schuster @ 2013-12-10 18:11 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 10.12.2013 um 17:54 schrieb Alan Braslau <alan.braslau@cea.fr>:

> Perhaps you might want to do something processing a comma separated
> list:
> 
> http://wiki.contextgarden.net/System_Macros/Comma_Separated_Lists


A short example can help to show how it can be used:

\def\test
  {\dosingleargument\dotest}

\def\dotest[#1]%
  {\starttabulate
   \NC 1 \EQ \getfromcommalist[#1][1]\commalistelement \NC\NR
   \NC 2 \EQ \getfromcommalist[#1][2]\commalistelement \NC\NR
   \stoptabulate}

\starttext
\test[First row,Second row]
\stoptext

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Understanding the basics of \define
  2013-12-10 15:57     ` Wolfgang Schuster
@ 2013-12-10 21:03       ` Peter Münster
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Münster @ 2013-12-10 21:03 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Tue, Dec 10 2013, Wolfgang Schuster wrote:

> One way to set values is the \getparameters command but the disadvantage
> of this is that you to ensure not to call values (e.g. \testthree) which aren’t set
> (e.g. not “three={…}” setting for the \test command).

You can preset the values: \getparameters[test][one=, two=my default 2, three=, #1]


> \def\test
>   {\dosingleargument\dotest}

Wouldn't it be better (for users who don't know the source by heart),
to use camelcase names (for example "\Test"), to avoid clashes with
internal ConTeXt macros?

-- 
           Peter
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Understanding the basics of \define
  2013-12-10 18:11           ` Wolfgang Schuster
@ 2013-12-11 12:31             ` Pavel Stupin
  2013-12-11 14:11               ` Wolfgang Schuster
  0 siblings, 1 reply; 11+ messages in thread
From: Pavel Stupin @ 2013-12-11 12:31 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Thank you everyone for your help! Quite excited about having so much
for me to learn. This mailing list is immensely helpful indeed. So,
both solutions worked for me, but I've decided to stick to the one
that uses comma separated list having adapted to my needs the code
kindly offered by Wolfgang (it would take me a while to figure out the
solution myself).

Kind regards, Pavel.

2013/12/11 Wolfgang Schuster <schuster.wolfgang@gmail.com>:
>
> Am 10.12.2013 um 17:54 schrieb Alan Braslau <alan.braslau@cea.fr>:
>
>> Perhaps you might want to do something processing a comma separated
>> list:
>>
>> http://wiki.contextgarden.net/System_Macros/Comma_Separated_Lists
>
>
> A short example can help to show how it can be used:
>
> \def\test
>   {\dosingleargument\dotest}
>
> \def\dotest[#1]%
>   {\starttabulate
>    \NC 1 \EQ \getfromcommalist[#1][1]\commalistelement \NC\NR
>    \NC 2 \EQ \getfromcommalist[#1][2]\commalistelement \NC\NR
>    \stoptabulate}
>
> \starttext
> \test[First row,Second row]
> \stoptext
>
> Wolfgang
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Understanding the basics of \define
  2013-12-11 12:31             ` Pavel Stupin
@ 2013-12-11 14:11               ` Wolfgang Schuster
  0 siblings, 0 replies; 11+ messages in thread
From: Wolfgang Schuster @ 2013-12-11 14:11 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 11.12.2013 um 13:31 schrieb Pavel Stupin <stupin.pavel@gmail.com>:

> Thank you everyone for your help! Quite excited about having so much
> for me to learn. This mailing list is immensely helpful indeed. So,
> both solutions worked for me, but I've decided to stick to the one
> that uses comma separated list having adapted to my needs the code
> kindly offered by Wolfgang (it would take me a while to figure out the
> solution myself).

When you process a comma list you can also loop over the entries in the list
which is faster than accessing each entry of the list one by one (I change in
the example to natural tables because tabulate can’t be used in this way):

\def\Test
  {\dosingleargument\doTest}

\def\doTest[#1]%
  {\newcounter\TestCounter
   \bTABLE
   \processcommalist[#1]\dodoTest
   \eTABLE}

\def\dodoTest#1%
  {\doglobal\increment\TestCounter
   \bTR \expanded{\bTD \TestCounter \eTD} \bTD #1 \eTD \eTR}

\starttext
\Test[First row,Second row]
\stoptext

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-12-11 14:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-10 11:23 Understanding the basics of \define Pavel Stupin
2013-12-10 13:42 ` Wolfgang Schuster
2013-12-10 14:24   ` Pavel Stupin
2013-12-10 15:17     ` Pavel Stupin
2013-12-10 15:29       ` Pavel Stupin
2013-12-10 16:54         ` Alan Braslau
2013-12-10 18:11           ` Wolfgang Schuster
2013-12-11 12:31             ` Pavel Stupin
2013-12-11 14:11               ` Wolfgang Schuster
2013-12-10 15:57     ` Wolfgang Schuster
2013-12-10 21:03       ` Peter Münster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).