Re: [NTG-context] \processcommalist and load values into macros.

2013-06-04 Thread Wolfgang Schuster

Am 03.06.2013 um 23:47 schrieb Jaroslav Hajtmar hajt...@gyza.cz:

 Hello ConTeXist.
 Obviously I have a problem with expansion. My question is:
 How can I place the elements of the list into macros for later use?
 Basically, my point is that I want assign individual values into macros 
 within the cycle of ​​and those subsequently used in a buffer to creating my 
 own report.
 Perhaps is can be understood what I want from my minimal example.


I suggest to use a different method to store and load the data. The first method
is to use the database module (you can also use a external file for the data),
the other method is the \setvariables command where you can use keys for
the entries.


Method 1:

\usemodule[database]

\define[5]\TestCommand
  {\starttabulate
   \NC FIRSTNAME \EQ #1 \NC\NR
   \NC SURNAME   \EQ #2 \NC\NR
   \NC CITY  \EQ #3 \NC\NR
   \NC STREET\EQ #4 \NC\NR
   \NC POSTCODE  \EQ #5 \NC\NR
   \stoptabulate
   \page}

\defineseparatedlist[test][command=\TestCommand]

\starttext

\starttest
John, Smith, Prague, Václavské náměstí 20, 11500
Peter, Paul, Brno, Nad struhou 232/12, 234 20
Annie, Walter, Ostrava, Pod lipami 7, 321 54
\stoptest

\stoptext


Method 2:

\startsetups[test]

  \starttabulate
  \NC FIRSTNAME \EQ \getvariable{test}{firstname} \NC\NR
  \NC SURNAME   \EQ \getvariable{test}{surname}   \NC\NR
  \NC CITY  \EQ \getvariable{test}{city}  \NC\NR
  \NC STREET\EQ \getvariable{test}{street}\NC\NR
  \NC POSTCODE  \EQ \getvariable{test}{postcode}  \NC\NR
  \stoptabulate

  \page

\stopsetups

\setvariable{test}{set}{\setups{test}}

\starttext

\setvariables
  [test]
  [firstname=John,
   surname=Smith,
   city=Prague,
   street=Václavské náměstí 20,
   postcode=11500]

\setvariables
  [test]
  [firstname=Peter,
   surname=Paul,
   city=Brno,
   street=Nad struhou 232/12,
   postcode=234 20]

\setvariables
  [test]
  [firstname=Annie,
   surname=Walter,
   city=Ostrava,
   street=Pod lipami 7,
   postcode=321 54]

\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
___

Re: [NTG-context] \processcommalist and load values into macros.

2013-06-04 Thread Jaroslav Hajtmar

Hello Wolfgang.
There is any problem in first method.
I get  message Nested tabulate is not (yet) supported.
Thanx Jaroslav Hajtmar

Here is problematic example:


\usemodule[database]



\define[5]\TestCommand
  {\starttabulate
   \NC FIRSTNAME \EQ #1 \NC\NR
   \NC SURNAME   \EQ #2 \NC\NR
   \NC CITY  \EQ #3 \NC\NR
   \NC STREET\EQ #4 \NC\NR
   \NC POSTCODE  \EQ #5 \NC\NR
   \stoptabulate
   \page}

\define[5]\TestOtherCommand{#1, #2, #3, #4, #5\par}


\defineseparatedlist[test][command=\TestCommand]

\defineseparatedlist[othertest][command=\TestOtherCommand]

\starttext

Method 1:

\starttest
John, Smith, Prague, Václavské náměstí 20, 115 00
Peter, Paul, Brno, Nad struhou 232/12, 234 20
Annie, Walter, Ostrava, Pod lipami 7, 321 54
\stoptest

\startothertest
John, Smith, Prague, Václavské náměstí 20, 115 00
Peter, Paul, Brno, Nad struhou 232/12, 234 20
Annie, Walter, Ostrava, Pod lipami 7, 321 54
\stopothertest


\stoptext



Dne 4.6.2013 19:34, Wolfgang Schuster napsal(a):

Am 03.06.2013 um 23:47 schrieb Jaroslav Hajtmar hajt...@gyza.cz:


Hello ConTeXist.
Obviously I have a problem with expansion. My question is:
How can I place the elements of the list into macros for later use?
Basically, my point is that I want assign individual values into macros within 
the cycle of ​​and those subsequently used in a buffer to creating my own 
report.
Perhaps is can be understood what I want from my minimal example.


I suggest to use a different method to store and load the data. The first method
is to use the database module (you can also use a external file for the data),
the other method is the \setvariables command where you can use keys for
the entries.


Method 1:

\usemodule[database]

\define[5]\TestCommand
   {\starttabulate
\NC FIRSTNAME \EQ #1 \NC\NR
\NC SURNAME   \EQ #2 \NC\NR
\NC CITY  \EQ #3 \NC\NR
\NC STREET\EQ #4 \NC\NR
\NC POSTCODE  \EQ #5 \NC\NR
\stoptabulate
\page}

\defineseparatedlist[test][command=\TestCommand]

\starttext

\starttest
John, Smith, Prague, Václavské náměstí 20, 11500
Peter, Paul, Brno, Nad struhou 232/12, 234 20
Annie, Walter, Ostrava, Pod lipami 7, 321 54
\stoptest

\stoptext


Method 2:

\startsetups[test]

   \starttabulate
   \NC FIRSTNAME \EQ \getvariable{test}{firstname} \NC\NR
   \NC SURNAME   \EQ \getvariable{test}{surname}   \NC\NR
   \NC CITY  \EQ \getvariable{test}{city}  \NC\NR
   \NC STREET\EQ \getvariable{test}{street}\NC\NR
   \NC POSTCODE  \EQ \getvariable{test}{postcode}  \NC\NR
   \stoptabulate

   \page

\stopsetups

\setvariable{test}{set}{\setups{test}}

\starttext

\setvariables
   [test]
   [firstname=John,
surname=Smith,
city=Prague,
street=Václavské náměstí 20,
postcode=11500]

\setvariables
   [test]
   [firstname=Peter,
surname=Paul,
city=Brno,
street=Nad struhou 232/12,
postcode=234 20]

\setvariables
   [test]
   [firstname=Annie,
surname=Walter,
city=Ostrava,
street=Pod lipami 7,
postcode=321 54]

\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
___

Re: [NTG-context] \processcommalist and load values into macros.

2013-06-04 Thread Wolfgang Schuster

Am 04.06.2013 um 20:26 schrieb Jaroslav Hajtmar hajt...@gyza.cz:

 Hello Wolfgang.
 There is any problem in first method.
 I get  message Nested tabulate is not (yet) supported.

There was a bug in the database module regarding the command key,
update your installation and it will work.

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
___


Re: [NTG-context] \processcommalist and load values into macros.

2013-06-04 Thread Jaroslav Hajtmar

Thanx Wolfgang very much.
After update standalone version of ConTeXt is first database method 
working OK.


You proposed methods are acceptable and comfortable for me. Moreover, it 
is systemic solutions.


Thanks very much for the reply and for the inspiration.
Jaroslav Hajtmar



Dne 4.6.2013 20:40, Wolfgang Schuster napsal(a):

Am 04.06.2013 um 20:26 schrieb Jaroslav Hajtmar hajt...@gyza.cz:


Hello Wolfgang.
There is any problem in first method.
I get  message Nested tabulate is not (yet) supported.

There was a bug in the database module regarding the command key,
update your installation and it will work.

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
___


[NTG-context] \processcommalist and load values into macros.

2013-06-03 Thread Jaroslav Hajtmar

Hello ConTeXist.
Obviously I have a problem with expansion. My question is:
How can I place the elements of the list into macros for later use?
Basically, my point is that I want assign individual values into macros 
within the cycle of ​​and those subsequently used in a buffer to 
creating my own report.

Perhaps is can be understood what I want from my minimal example.

Thanx
Jaroslav Hajtmar

Minimal example:


\let\filename\null
\let\firstname\null
\let\surname\null
\let\city\null
\let\street\null
\let\postcode\null


\def\dosomething#1{#1\par}

\def\loadlistdatatomacros#1,#2,#3,#4,#5 {
\global\def\firstname{#1}
\global\def\surname{#2}
\global\def\town{#3}
\global\def\street{#4}
\global\def\postcode{#5}
}




\startbuffer[mypostbuffer]
\dosomething

% \loadlistdatatomacros
FIRSTNAME: \firstname\par
SURNAME: \surname\par
CITY \city\par
STREET \street\par
POSTCODE \postcode\par
\page
\stopbuffer


\starttext


\processcommalist[
{John, Smith, Prague, Václavské náměstí 20, 11500 },
{Peter, Paul, Brno, Nad struhou 232/12, 234 20 },
{Annie, Walter, Ostrava, Pod lipami 7, 321 54 },
]{\getbuffer[mypostbuffer]}


\stoptext

___
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
___