Re: [NTG-context] \setvariables and database module

2018-02-01 Thread luigi scarso
On Wed, Jan 31, 2018 at 10:20 PM, Otared Kavian  wrote:
>
>
>> On 31 Jan 2018, at 18:11, Wolfgang Schuster  
>> wrote:
>>
>>> […]
>>> Thanks again, but I wonder where did you find this trick?… in i-context.pdf 
>>> there is no entry for \defineseparatedlist…
>>
>> setup-en.pdf (and i-context.pdf) contains only commands from the core. There 
>> are lists for many modules (e.g. i-database.xml contains the options for the 
>> database module) but no PDF which shows them.
>
> Indeed looking for the file i-database.xml I discovered that in
> context-minimal/tex/texmf-context/tex/context/interface/mkiv/
> there are lots of file such as i-ABC.xml, which can be typeset in order to 
> obtain a pdf.
> A great piece of information… thanks!
In the same folder:
i-context.pdf
i-readme.pdf



-- 
luigi
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] \setvariables and database module

2018-01-31 Thread Otared Kavian


> On 31 Jan 2018, at 18:11, Wolfgang Schuster  
> wrote:
> 
>> […]
>> Thanks again, but I wonder where did you find this trick?… in i-context.pdf 
>> there is no entry for \defineseparatedlist…
> 
> setup-en.pdf (and i-context.pdf) contains only commands from the core. There 
> are lists for many modules (e.g. i-database.xml contains the options for the 
> database module) but no PDF which shows them.

Indeed looking for the file i-database.xml I discovered that in
context-minimal/tex/texmf-context/tex/context/interface/mkiv/
there are lots of file such as i-ABC.xml, which can be typeset in order to 
obtain a pdf. 
A great piece of information… thanks!

Best regards: OK

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] \setvariables and database module

2018-01-31 Thread Wolfgang Schuster



Otared Kavian 
31. Januar 2018 um 17:58

Yes it does the job!
Thanks again, but I wonder where did you find this trick?… in 
i-context.pdf there is no entry for \defineseparatedlist…


setup-en.pdf (and i-context.pdf) contains only commands from the core. 
There are lists for many modules (e.g. i-database.xml contains the 
options for the database module) but no PDF which shows them.


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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] \setvariables and database module

2018-01-31 Thread Otared Kavian


> On 31 Jan 2018, at 17:40, Wolfgang Schuster  
> wrote:
> 
>> […]
>> 
> Add “strip=yes” to remove spaces around the cells.
> 
> \defineseparatedlist
>   [seplisttalk]
>   [separator={;},
>command=\maketalk,
>strip=yes]
> 

Yes it does the job! 
Thanks again, but I wonder where did you find this trick?… in i-context.pdf 
there is no entry for \defineseparatedlist…

Best regards: OK___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] \setvariables and database module

2018-01-31 Thread Wolfgang Schuster



Otared Kavian 
30. Januar 2018 um 16:53
Hi again Wolfgang,

I think I understood what is going wrong with my example after your 
hint: I have to remove all spaces around the separator and remove also 
the braces around each entry.

That is the following works fine:

\startseplisttalk
Hacker;Up to date hacking;hacker.jpg
Hacker;Up to date hacking;hacker.jpg
\stopseplisttalk

while the following does not (as far as the filename is concerned):

\startseplisttalk
{Hacker};{Up to date hacking};{hacker.jpg}
Hacker ; Up to date hacking ; hacker.jpg
\stopseplisttalk


Add “strip=yes” to remove spaces around the cells.

\defineseparatedlist
  [seplisttalk]
  [separator={;},
   command=\maketalk,
   strip=yes]

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] \setvariables and database module

2018-01-30 Thread Otared Kavian


> On 30 Jan 2018, at 19:05, Wolfgang Schuster  
> wrote:
>> […]
> Spaces after a control sequence are gobbled and multiple spaces are skipped.
> 
> Braces around the filename are allowed because this function was added with 
> the extensions to the TeX binary (which means it doesn’t work with Knuths 
> original TeX), try this \input{ knuth.tex} to load a file with a space in the 
> name.

Yes, I understand now the rationale behind this behavior.
Many thanks!___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] \setvariables and database module

2018-01-30 Thread Wolfgang Schuster



Otared Kavian 
30. Januar 2018 um 18:56

Thanks again! That does it.

However, it seems strange that the \externalfigure command does not 
accept a space in front of the file name nor after the file extension, 
while \input is very tolerant in that respect. Compare


\input   knuth.tex
\input knuth.tex
\input{knuth.tex}


Spaces after a control sequence are gobbled and multiple spaces are skipped.

Braces around the filename are allowed because this function was added 
with the extensions to the TeX binary (which means it doesn’t work with 
Knuths original TeX), try this \input{ knuth.tex} to load a file with a 
space in the name.


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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] \setvariables and database module

2018-01-30 Thread Otared Kavian
> On 30 Jan 2018, at 17:37, Wolfgang Schuster  
> wrote:
> 
>> […]
>> Is there a way to make the \defineseparatedlist command to be more tolerant 
>> for the filename? 
>> 
> No but you can remove the space with Lua.
> 
> \externalfigure[\cldcontext{string.collapsespaces("\getvariable{talk}{picture}")}]
> 

Thanks again! That does it.

However, it seems strange that the \externalfigure command does not accept a 
space in front of the file name nor after the file extension, while \input is 
very tolerant in that respect. Compare

\input   knuth.tex   
\input knuth.tex
\input{knuth.tex}

which are all accepted, while when there is a space after the extension,

\startplacefigure[number=no]
\externalfigure[hacker.jpg ]
\stopplacefigure

or a space before the filename 

\startplacefigure[number=no]
\externalfigure[ hacker.jpg]
\stopplacefigure

then ConTeXt does not recognize the file…
Maybe Hans has a reason to explain this behavior, but it is not clear to me.

Best regards: OK


___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] \setvariables and database module

2018-01-30 Thread Wolfgang Schuster



Otared Kavian 
30. Januar 2018 um 16:53
Hi again Wolfgang,

I think I understood what is going wrong with my example after your 
hint: I have to remove all spaces around the separator and remove also 
the braces around each entry.

That is the following works fine:

\startseplisttalk
Hacker;Up to date hacking;hacker.jpg
Hacker;Up to date hacking;hacker.jpg
\stopseplisttalk

while the following does not (as far as the filename is concerned):

\startseplisttalk
{Hacker};{Up to date hacking};{hacker.jpg}
Hacker ; Up to date hacking ; hacker.jpg
\stopseplisttalk

Is there a way to make the \defineseparatedlist command to be more 
tolerant for the filename?



No but you can remove the space with Lua.

\externalfigure[\cldcontext{string.collapsespaces("\getvariable{talk}{picture}")}]

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] \setvariables and database module

2018-01-30 Thread Otared Kavian
Hi again Wolfgang,

I think I understood what is going wrong with my example after your hint: I 
have to remove all spaces around the separator and remove also the braces 
around each entry.
That is the following works fine:

\startseplisttalk
Hacker;Up to date hacking;hacker.jpg
Hacker;Up to date hacking;hacker.jpg
\stopseplisttalk

while the following does not (as far as the filename is concerned):

\startseplisttalk
{Hacker};{Up to date hacking};{hacker.jpg}
Hacker ; Up to date hacking ; hacker.jpg
\stopseplisttalk

Is there a way to make the \defineseparatedlist command to be more tolerant for 
the filename? 
Best regards: OK

> On 30 Jan 2018, at 16:28, Otared Kavian <ota...@gmail.com> wrote:
> 
> 
>> On 30 Jan 2018, at 15:54, Wolfgang Schuster <schuster.wolfg...@gmail.com 
>> <mailto:schuster.wolfg...@gmail.com>> wrote:
>>> […]
>> 
>> Use the command key which grabs the content of each column as argument (i.e. 
>> your commands needs as many arguments as your table has columns):
>> 
>> \defineseparatedlist
>>   [seplisttalk]
>>   [separator={;},
>>command=\maketalk]
> 
> 
> Thanks Wolfgang! That fixes the issues concerning the entries which are text, 
> but now the filename is not understood by the command \maketalk: here is the 
> modified code:
> 
> %% begin database-command.tex
> \usemodule[database]
> 
> \starttext
> \startbuffer[pagetalk]
>   \starttabulate[|f{\bi}l|p|][before=]%
>   \NC Speaker \EQ 
>   \goto{{\sc 
> \getvariable{talk}{speakername}}}[fig:\getvariable{talk}{speakername}]
>\NC\NR
>   \NC Title   \EQ \getvariable{talk}{title}\NC\NR
>   \stoptabulate
>   \startplacefigure[number=no]
>   \externalfigure[\getvariable{talk}{picture}]
>   \stopplacefigure
>   \page
> \stopbuffer
> 
> \setvariable{talk}{set}{\getbuffer[pagetalk]}
> 
> \define[3]\maketalk{%
>   \setvariables[talk]%
>   [speakername={#1},
>   title={#2},
>   picture={#3},
>   ]}
> 
> \defineseparatedlist[seplisttalk]
>   [separator={;},
>   command=\maketalk]
> 
> \startseplisttalk
> {Hacker} ; {Up to date hacking} ; {hacker.jpg}
> Hacker ; Up to date hacking ; hacker.jpg
> \stopseplisttalk
> 
> \stoptext
> %% end database-command.tex

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] \setvariables and database module

2018-01-30 Thread Otared Kavian

> On 30 Jan 2018, at 15:54, Wolfgang Schuster <schuster.wolfg...@gmail.com> 
> wrote:
>> […]
> 
> Use the command key which grabs the content of each column as argument (i.e. 
> your commands needs as many arguments as your table has columns):
> 
> \defineseparatedlist
>   [seplisttalk]
>   [separator={;},
>command=\maketalk]


Thanks Wolfgang! That fixes the issues concerning the entries which are text, 
but now the filename is not understood by the command \maketalk: here is the 
modified code:

%% begin database-command.tex
\usemodule[database]

\starttext
\startbuffer[pagetalk]
\starttabulate[|f{\bi}l|p|][before=]%
\NC Speaker \EQ 
\goto{{\sc 
\getvariable{talk}{speakername}}}[fig:\getvariable{talk}{speakername}]
 \NC\NR
\NC Title   \EQ \getvariable{talk}{title}\NC\NR
\stoptabulate
\startplacefigure[number=no]
\externalfigure[\getvariable{talk}{picture}]
\stopplacefigure
\page
\stopbuffer

\setvariable{talk}{set}{\getbuffer[pagetalk]}

\define[3]\maketalk{%
\setvariables[talk]%
[speakername={#1},
title={#2},
picture={#3},
]}

\defineseparatedlist[seplisttalk]
[separator={;},
command=\maketalk]

\startseplisttalk
{Hacker} ; {Up to date hacking} ; {hacker.jpg}
Hacker ; Up to date hacking ; hacker.jpg
\stopseplisttalk

\stoptext
%% end database-command.tex___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] \setvariables and database module

2018-01-30 Thread Wolfgang Schuster



Otared Kavian <mailto:ota...@gmail.com>
30. Januar 2018 um 15:44
Hi all,

I need to create a document using a database and the \setvariables 
command (which I understood thanks to Wolfgang Schuster). Everything 
works fine except that using the approach below I need to change the 
entries in the database by enclosing each entry between a pair of 
braces {}, because otherwise the macro I have imagined does not work 
as expected. In the example below the first line of entries is treated 
correctly, while the second one is understood wrongly by my macro 
\maketalk defined below in the minimal example.


It is indeed possible, in theory, to change the database file so that 
each entry is enclosed in a pair of braces, but I would like to avoid 
that mainly because I am not the one who produces nor maintains that 
file and I want to avoid modifying a copy of that file myself.


How can I change my approach to this problem in order to achieve what 
is needed?

Many thanks for any hint.
Best regards: OK

% begin database-command.tex
\usemodule[database]

\starttext
\startbuffer[pagetalk]
\starttabulate[|f{\bi}l|p|][before=]%
\NC Speaker \EQ
\goto{{\sc 
\getvariable{talk}{speakername}}}[fig:\getvariable{talk}{speakername}]

\NC\NR
\NC Title \EQ \getvariable{talk}{title} \NC\NR
\stoptabulate
\startplacefigure[number=no]
\externalfigure[\getvariable{talk}{picture}]
\stopplacefigure
\page
\stopbuffer

\setvariable{talk}{set}{\getbuffer[pagetalk]}

\define[3]\maketalk{%
\setvariables[talk]%
[speakername={#1},
title={#2},
picture={#3},
]}

\defineseparatedlist[seplisttalk]
[separator={;},
first=\maketalk
]


Use the command key which grabs the content of each column as argument 
(i.e. your commands needs as many arguments as your table has columns):


\defineseparatedlist
  [seplisttalk]
  [separator={;},
   command=\maketalk]

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

[NTG-context] \setvariables and database module

2018-01-30 Thread Otared Kavian
Hi all,

I need to create a document using a database and the \setvariables command 
(which I understood thanks to Wolfgang Schuster). Everything works fine except 
that using the approach below I need to change the entries in the database by 
enclosing each entry between a pair of braces {}, because otherwise the macro I 
have imagined does not work as expected. In the example below the first line of 
entries is treated correctly, while the second one is understood wrongly by my 
macro \maketalk defined below in the minimal example.

It is indeed possible, in theory, to change the database file so that each 
entry is enclosed in a pair of braces, but I would like to avoid that mainly 
because I am not the one who produces nor maintains that file and I want to 
avoid modifying a copy of that file myself.

How can I change my approach to this problem in order to achieve what is needed?
Many thanks for any hint.
Best regards: OK

% begin database-command.tex
\usemodule[database]

\starttext
\startbuffer[pagetalk]
\starttabulate[|f{\bi}l|p|][before=]%
\NC Speaker \EQ 
\goto{{\sc 
\getvariable{talk}{speakername}}}[fig:\getvariable{talk}{speakername}]
 \NC\NR
\NC Title   \EQ \getvariable{talk}{title}\NC\NR
\stoptabulate
\startplacefigure[number=no]
\externalfigure[\getvariable{talk}{picture}]
\stopplacefigure
\page
\stopbuffer

\setvariable{talk}{set}{\getbuffer[pagetalk]}

\define[3]\maketalk{%
\setvariables[talk]%
[speakername={#1},
title={#2},
picture={#3},
]}

\defineseparatedlist[seplisttalk]
[separator={;},
first=\maketalk
]

\startseplisttalk
{Hacker} ; {Up to date hacking} ; {hacker.jpg} % this works fine
Hacker ; Up to date hacking ; hacker.jpg % this does not work: the macro takes 
only the three characters H a c
\stopseplisttalk

\stoptext
% end database-command.tex
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

[NTG-context] Working with variables in MkIV (\ setvariables, \getparameters etc)

2012-09-09 Thread Jaroslav Hajtmar

Hello ConTeXist,

Is it possible go through  all the keys of \setvariables (getvariable) 
macro and create the appropriate macros, as in the case of 
\getparameters macro?


I mean macro like \getallvariablesfrom[myfirstnamespace], which return 
contents of brackets macro \setvariables[myfirstnamespace] (it mean list 
of all assignments key=value ...)


In addition, you can assign all the variables one namespace to another 
namespace (or to create a loop which all variables passed and placed 
into the other namespace.)?


Thanx Jaroslav Hajtmar

Here is my inspiration of example :


\setvariables[myfirstnamespace][id=1, value={text}]

\starttext

% \getparameters[myfirstnamespace][\getallvariablesfrom[myfirstnamespace]]

% Now would be defined  macros \myfirstnamespaceid  (1) and 
\myfirstnamespacevalue  (text)



% Assign all the variables of [myfirstnamespace] namespace to 
[myotherspace] namespace?

%\setvariable[myotherspace][\getallvariablesfrom[myfirstnamespace]]

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


Re: [NTG-context] Working with variables in MkIV (\ setvariables, \getparameters etc)

2012-09-09 Thread Wolfgang Schuster

Am 09.09.2012 um 10:42 schrieb Jaroslav Hajtmar hajt...@gyza.cz:

 Hello ConTeXist,
 
 Is it possible go through  all the keys of \setvariables (getvariable) macro 
 and create the appropriate macros, as in the case of \getparameters macro?
 
 I mean macro like \getallvariablesfrom[myfirstnamespace], which return 
 contents of brackets macro \setvariables[myfirstnamespace] (it mean list of 
 all assignments key=value ...)
 
 In addition, you can assign all the variables one namespace to another 
 namespace (or to create a loop which all variables passed and placed into the 
 other namespace.)?
 
 Thanx Jaroslav Hajtmar
 
 Here is my inspiration of example :
 
 
 \setvariables[myfirstnamespace][id=1, value={text}]
 
 \starttext
 
 % \getparameters[myfirstnamespace][\getallvariablesfrom[myfirstnamespace]]
 
 % Now would be defined  macros \myfirstnamespaceid  (1) and 
 \myfirstnamespacevalue  (text)
 
 
 % Assign all the variables of [myfirstnamespace] namespace to [myotherspace] 
 namespace?
 %\setvariable[myotherspace][\getallvariablesfrom[myfirstnamespace]]
 
 \stoptext

There is no way to access the list with the parameters from \setvariables but 
the question why you
want a command for each variable. In MkIV direct use of values in the form 
\myfirstnamespaceid
are replaced with something like \mynamespaceparameter{id} which has the 
advantage that you
can even use keys which haven’t been assigned before.

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] Working with variables in MkIV (\ setvariables, \getparameters etc)

2012-09-09 Thread Jaroslav Hajtmar

Thanx Wolfgang.

I do not know anything about such a possibility.
What do you mean? Can you show a simple example?
I tried several options but nothing works. Here are some examples:

\setvariables[myspacename][id=1, value={value}]

\getparameters[myotherspacename][id=1, value={value}]

\starttext

% \myspacenameid % not work
% \myspacename{id} % not work
% \myspacenameparameter{id} % not work
% ???

\myotherspacenameid % this works only




\stoptext


Thanx Jaroslav Hajtmar




Dne 9.9.2012 11:35, Wolfgang Schuster napsal(a):

Am 09.09.2012 um 10:42 schrieb Jaroslav Hajtmarhajt...@gyza.cz:

   

Hello ConTeXist,

Is it possible go through  all the keys of \setvariables (getvariable) macro 
and create the appropriate macros, as in the case of \getparameters macro?

I mean macro like \getallvariablesfrom[myfirstnamespace], which return contents 
of brackets macro \setvariables[myfirstnamespace] (it mean list of all 
assignments key=value ...)

In addition, you can assign all the variables one namespace to another 
namespace (or to create a loop which all variables passed and placed into the 
other namespace.)?

Thanx Jaroslav Hajtmar

Here is my inspiration of example :


\setvariables[myfirstnamespace][id=1, value={text}]

\starttext

% \getparameters[myfirstnamespace][\getallvariablesfrom[myfirstnamespace]]

% Now would be defined  macros \myfirstnamespaceid  (1) and 
\myfirstnamespacevalue  (text)


% Assign all the variables of [myfirstnamespace] namespace to [myotherspace] 
namespace?
%\setvariable[myotherspace][\getallvariablesfrom[myfirstnamespace]]

\stoptext
 

There is no way to access the list with the parameters from \setvariables but 
the question why you
want a command for each variable. In MkIV direct use of values in the form 
\myfirstnamespaceid
are replaced with something like \mynamespaceparameter{id} which has the 
advantage that you
can even use keys which haven’t been assigned before.

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] Working with variables in MkIV (\ setvariables, \getparameters etc)

2012-09-09 Thread Jaroslav Hajtmar

Thanx Wolfgang.

So far I have never worked with namespaces as follows. I thought that 
\setvariables macro automatically namespace for variables creates and 
sets the values in it. Setvariables somehow connected with the creation 
of macro variables in the namespace of the given name? It appears that 
the following example shows that it is not ...


\starttext

\definenamespace[myspace][name=myspace,command=yes,setup=yes,parent=one]

\setupmyspace[
id=3,
graphcolor=green,
]


\setvariables[myspace][
id=5,
graphcolor=blue,
]


\myspaceparameter{id}

\myspaceparameter{graphcolor}


\stoptext



Thanx Jaroslav




Dne 9.9.2012 12:45, Wolfgang Schuster napsal(a):

Am 09.09.2012 um 12:35 schrieb Jaroslav Hajtmarhajt...@gyza.cz:

   

  Thanx Wolfgang.
  
  I do not know anything about such a possibility.

  What do you mean? Can you show a simple example?
  I tried several options but nothing works. Here are some examples:
  
  \setvariables[myspacename][id=1, value={value}]
  
  \getparameters[myotherspacename][id=1, value={value}]
  
  \starttext
  
  % \myspacenameid % not work

  % \myspacename{id} % not work
  % \myspacenameparameter{id} % not work
  % ???
  
  \myotherspacenameid % this works only
  
  \stoptext
 

When you use \getparameter you have to define the command yourself, e.g.

   \def\mynamespaceid#1{\csname mynamespace#1\endcsname}

or you use \definenamespace which creates all these commands for you:

\starttext

\definenamespace[one][name=one,command=yes,setup=yes,parent=one]
\definenamespace[two][name=two,command=yes,setup=yes,parent=one]

% With this parent setting \twoparameter uses the values from \setupone
% when no value is set with \setuptwo.

\unprotect
\setuptwo[parent=\one]
\protect

\setupone[one=One,two=Two]

\starttabulate
\NC one:one \EQ \oneparameter{one} \NC\NR
\NC one:two \EQ \oneparameter{two} \NC\NR
\NC two:one \EQ \twoparameter{one} \NC\NR
\NC two:one \EQ \twoparameter{two} \NC\NR
\stoptabulate

\setuptwo[one=1,two=2]

\starttabulate
\NC one:one \EQ \oneparameter{one} \NC\NR
\NC one:two \EQ \oneparameter{two} \NC\NR
\NC two:one \EQ \twoparameter{one} \NC\NR
\NC two:one \EQ \twoparameter{two} \NC\NR
\stoptabulate

\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] Working with variables in MkIV (\ setvariables, \getparameters etc)

2012-09-09 Thread Wolfgang Schuster

Am 09.09.2012 um 13:56 schrieb Jaroslav Hajtmar hajt...@gyza.cz:

 Thanx Wolfgang.
 
 So far I have never worked with namespaces as follows. I thought that 
 \setvariables macro automatically namespace for variables creates and sets 
 the values in it. Setvariables somehow connected with the creation of macro 
 variables in the namespace of the given name? It appears that the following 
 example shows that it is not …

The internal functioning of both methods is more or less the same, I will begin 
with \getparameters.

To set values as key-value-list you can use the \getparameters command, e.g.

  \getparameters[namespace][key1=value1,key2=value2,…]

When ConTeXt process this list it takes each entry which till the next comma or 
the end of the list and splits it in two parts which are on the left (the 
“key”)and the right (the “value”) of the = sign. After that it creates a new 
command whose name consist of the namespace and key, e.g. “\namespacekye1” 
which stores the content of the key, e.g. “value1”. To create the command which 
stores the value context uses \csname/\endcsname which allows one to use 
numbers, spaces etc. as part of the key.


The \setvariables command is a wrapper around \getparameters to store values in 
a certain namespace which can only be accessed with the \getvariable command.


With \definenamespace you can generate \setup… and \define… command which use 
itself \getparameters to store the values but the namespace itself uses symbols 
(? and @) which can’t be normally used to create a command.


What you always have to keep in mind is that what we call a namespace is 
nothing more than a certain string a command names which makes it possible to 
distinguish them because there a many setups which have a width key, e.g. 
tables can “\tablewidth” to store the value of the key while figures use 
“\figurewidth” to store the value etc.

In reality context uses namespace like “@@ef” in MkII and in MkIV namespace 
have the form “123” where instead of letters numbers are used.

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] Working with variables in MkIV (\ setvariables, \getparameters etc)

2012-09-09 Thread Jaroslav Hajtmar


Thanx Wolfgang
for your explanations.

Jaroslav Hajtmar


Dne 9.9.2012 14:44, Wolfgang Schuster napsal(a):

Am 09.09.2012 um 13:56 schrieb Jaroslav Hajtmarhajt...@gyza.cz:

   

Thanx Wolfgang.

So far I have never worked with namespaces as follows. I thought that 
\setvariables macro automatically namespace for variables creates and sets the 
values in it. Setvariables somehow connected with the creation of macro 
variables in the namespace of the given name? It appears that the following 
example shows that it is not …
 

The internal functioning of both methods is more or less the same, I will begin 
with \getparameters.

To set values as key-value-list you can use the \getparameters command, e.g.

   \getparameters[namespace][key1=value1,key2=value2,…]

When ConTeXt process this list it takes each entry which till the next comma or 
the end of the list and splits it in two parts which are on the left (the 
“key”)and the right (the “value”) of the = sign. After that it creates a new 
command whose name consist of the namespace and key, e.g. “\namespacekye1” 
which stores the content of the key, e.g. “value1”. To create the command which 
stores the value context uses \csname/\endcsname which allows one to use 
numbers, spaces etc. as part of the key.


The \setvariables command is a wrapper around \getparameters to store values in 
a certain namespace which can only be accessed with the \getvariable command.


With \definenamespace you can generate \setup… and \define… command which use 
itself \getparameters to store the values but the namespace itself uses symbols 
(? and @) which can’t be normally used to create a command.


What you always have to keep in mind is that what we call a namespace is 
nothing more than a certain string a command names which makes it possible to 
distinguish them because there a many setups which have a width key, e.g. 
tables can “\tablewidth” to store the value of the key while figures use 
“\figurewidth” to store the value etc.

In reality context uses namespace like “@@ef” in MkII and in MkIV namespace have 
the form “123” where instead of letters numbers are used.

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] processing of setvariables/getvariables again

2005-10-24 Thread Thomas A. Schmitz

Taco,

thanks so much! With a slight modification, your solution seems to  
work! I will have to test it a bit, but for the moment, it looks very  
good. Is  the \appendtoks expensive in terms of TeX memory, cpu  
cycles, etc., or is it a good solution for the time being?


All best, and many thanks

Thomas

On Oct 22, 2005, at 10:55 AM, Taco Hoekwater wrote:



That is not what I meant. What (I think) you want is more like this:

 \def\initializegreekfont%
  {\starttypescript[Greek]
   \definetypeface [My\getvariable{Greek}{font}] [rm] [serif]
[\getvariable{Greek}{font}] [default] [encoding=agr]
   \stoptypescript
   \startsetups[enablegreek]
\catcode`~=\other
\catcode`|=\other
\catcode`'=\other
\language[greek]
\switchtobodyfont[My\getvariable{Greek}{font}]
\stopsetups }
 \appendtoks \initializegreekfont \to \everystarttext

In this way, you postpone all stuff that depends on the user-supplied
variables until the occurance of \starttext. I hope you can understand
me better now

Cheers, Taco
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context



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


Re: [NTG-context] processing of setvariables/getvariables again

2005-10-24 Thread Taco Hoekwater

Thomas A. Schmitz wrote:


Is the \appendtoks expensive in terms of TeX memory, cpu  cycles, 
etc., or is it a good solution for the time being?


This solution is perfectly OK. If there was a way to pass
arguments through \usemodule, that would be nicer, but if
that never happens, this will solution be fine.

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


Re: [NTG-context] processing of setvariables/getvariables again

2005-10-22 Thread Taco Hoekwater

Thomas A. Schmitz wrote:

Taco,

I tried your suggestion, but I'm not sure I'm doing it the right way.  I 
took the definition of \initialize... like so:


\def\initializegreekfont%
{\getvariable{Greek}{font}}
   \appendtoks \initializegreekfont \to \everystarttext % I guess I  
will need a similar procedure for%  


That is not what I meant. What (I think) you want is more like this:

 \def\initializegreekfont%
  {\starttypescript[Greek]
   \definetypeface [My\getvariable{Greek}{font}] [rm] [serif]
[\getvariable{Greek}{font}] [default] [encoding=agr]
   \stoptypescript
   \startsetups[enablegreek]
\catcode`~=\other
\catcode`|=\other
\catcode`'=\other
\language[greek]
\switchtobodyfont[My\getvariable{Greek}{font}]
\stopsetups }
 \appendtoks \initializegreekfont \to \everystarttext

In this way, you postpone all stuff that depends on the user-supplied
variables until the occurance of \starttext. I hope you can understand
me better now

Cheers, Taco
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] processing of setvariables/getvariables again

2005-10-21 Thread Taco Hoekwater


Hi Thomas,

It looks like you are looking for (inside the module):

  \def\initializegreek
{\switchtobodyfont[My\getvariable{Greek}{font}]}
  \appendtoks \initialize \to \everystarttext

There is no other way to get arguments to/from the module.
For Hans: it would be really cool if there was a way to
do something like this:

  \usemodule[greek][font=GreekGentium,scale=0.9]

with (in this example) the \usemodule command defining the
variables

  \moduleoptionfont
  \moduleoptionscale

etc.

Greetings, Taco

Thomas A. Schmitz wrote:

Hi all,

excuse me for being so pig-headed, but I'm running into the same  
problem I had two weeks ago. Peter Rolf was incredibly helpful, but I  
couldnt get things working. It is more a problem of architecture and  
general choices, IMHO, than of actual code. I tried every single part  
of what I want to achieve, and it works. The difficulty lies in  getting 
the variables to work...


Basic problem: I want to refine my greek module. It provides a command

\setupgreek[font=,scale=]

which sets variables fonts and scale in the namespace Greek. The  
command is defined in the module, so in order to use it, the module  has 
to be read. BUT: I want to use the result [i.e. \getvariable 
{Greek}{font} and \getvariable{Greek}{scale}] within the module  itself. 
Is this possible?


Details: I want to organize the fonts in a typescript to be more  
flexible. So the module first defines the setupcommand:


\def\setupgreek{\setvariables[Greek]}

then it calls the typescript

\usetypescriptfile[type-tasgreek]

where all the Greek fonts are defined in this form:

\starttypescript [serif] [GreekGentium] [agr]
  \definefontsynonym [Greekgentium-Roman] [genagr-GentiumAlt]   
[encoding=agr]
  \definefontsynonym [Greekgentium-Italic][genagr-GentiumAItI]  
[encoding=agr]

\stoptypescript

\starttypescript [serif] [GreekGentium] [name]
  \usetypescript[serif][fallback]
  \definefontsynonym [Serif]   [Greekgentium-Roman]
  \definefontsynonym [SerifItalic] [Greekgentium-Italic]
  \definefontsynonym [SerifBold]   [Serif]
  \definefontsynonym [SerifBoldItalic] [Serif]
\stoptypescript

So the module calls the typescriptfile (or would it be more elegant  to 
include these typescripts in the module itself?)


I then have the definition for the command \localgreek which  contains, 
among other things, a call of the Greek font. I had been  planning to 
implement it in this form:


\definetypeface [My\getvariable{Greek}{font}] [rm] [serif]  
[\getvariable{Greek}{font}] [default] [rscale = \getvariable{Greek} 
{font},encoding=agr]


and then, in the setups for \localgreek,

\switchtobodyfont[My\getvariable{Greek}{font}]

And that's where I'm banging my head against the wall: the module  would 
be used like this


\usemodule[t-greek]
\setupgreek[font=GreekGentium,scale=0.9]

Which means: the entire module will be read BEFORE the \setupgreek  
command. But I would need the values of the setupgreek command WITHIN  
the module. Is that possible at all? Would I have to call a third  file 
where the values are then processed? I tried to look into the  source 
how \setup commands work, but I do get the impression that  collecting 
the values and processing them is done in different files.  Is this 
necessary? And how could I implement it in one module?


Sorry if this sounds confusing, but I'm pretty confused, and hoping  for 
enlightenment from the wizzards.


All best

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

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


Re: [NTG-context] processing of setvariables/getvariables again

2005-10-21 Thread Taco Hoekwater



Taco Hoekwater wrote:


Hi Thomas,

It looks like you are looking for (inside the module):

  \def\initializegreek
{\switchtobodyfont[My\getvariable{Greek}{font}]}
  \appendtoks \initialize \to \everystarttext


Sorry, of course this should read:

  \appendtoks \initializegreek \to \everystarttext

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


Re: [NTG-context] processing of setvariables/getvariables again

2005-10-21 Thread Thomas A. Schmitz

Hi Taco,

thanks for your reply!! I have to catch a train now, but I'll try  
your suggestion tonight when I'm back. And yes, having the  
modulesomething variables would be great.


What does \appendtoks do?

Thanks, and all best

Thomas

On Oct 21, 2005, at 10:24 AM, Taco Hoekwater wrote:



Hi Thomas,

It looks like you are looking for (inside the module):

  \def\initializegreek
{\switchtobodyfont[My\getvariable{Greek}{font}]}
  \appendtoks \initialize \to \everystarttext

There is no other way to get arguments to/from the module.
For Hans: it would be really cool if there was a way to
do something like this:

  \usemodule[greek][font=GreekGentium,scale=0.9]

with (in this example) the \usemodule command defining the
variables

  \moduleoptionfont
  \moduleoptionscale

etc.

Greetings, Taco

Thomas A. Schmitz wrote:


Hi all,
excuse me for being so pig-headed, but I'm running into the same   
problem I had two weeks ago. Peter Rolf was incredibly helpful,  
but I  couldnt get things working. It is more a problem of  
architecture and  general choices, IMHO, than of actual code. I  
tried every single part  of what I want to achieve, and it works.  
The difficulty lies in  getting the variables to work...
Basic problem: I want to refine my greek module. It provides a  
command

\setupgreek[font=,scale=]
which sets variables fonts and scale in the namespace Greek. The   
command is defined in the module, so in order to use it, the  
module  has to be read. BUT: I want to use the result [i.e.  
\getvariable {Greek}{font} and \getvariable{Greek}{scale}] within  
the module  itself. Is this possible?
Details: I want to organize the fonts in a typescript to be more   
flexible. So the module first defines the setupcommand:

\def\setupgreek{\setvariables[Greek]}
then it calls the typescript
\usetypescriptfile[type-tasgreek]
where all the Greek fonts are defined in this form:
\starttypescript [serif] [GreekGentium] [agr]
  \definefontsynonym [Greekgentium-Roman] [genagr-GentiumAlt]
[encoding=agr]
  \definefontsynonym [Greekgentium-Italic][genagr-GentiumAItI]   
[encoding=agr]

\stoptypescript
\starttypescript [serif] [GreekGentium] [name]
  \usetypescript[serif][fallback]
  \definefontsynonym [Serif]   [Greekgentium-Roman]
  \definefontsynonym [SerifItalic] [Greekgentium-Italic]
  \definefontsynonym [SerifBold]   [Serif]
  \definefontsynonym [SerifBoldItalic] [Serif]
\stoptypescript
So the module calls the typescriptfile (or would it be more  
elegant  to include these typescripts in the module itself?)
I then have the definition for the command \localgreek which   
contains, among other things, a call of the Greek font. I had  
been  planning to implement it in this form:
\definetypeface [My\getvariable{Greek}{font}] [rm] [serif]   
[\getvariable{Greek}{font}] [default] [rscale = \getvariable 
{Greek} {font},encoding=agr]

and then, in the setups for \localgreek,
\switchtobodyfont[My\getvariable{Greek}{font}]
And that's where I'm banging my head against the wall: the module   
would be used like this

\usemodule[t-greek]
\setupgreek[font=GreekGentium,scale=0.9]
Which means: the entire module will be read BEFORE the  
\setupgreek  command. But I would need the values of the  
setupgreek command WITHIN  the module. Is that possible at all?  
Would I have to call a third  file where the values are then  
processed? I tried to look into the  source how \setup commands  
work, but I do get the impression that  collecting the values and  
processing them is done in different files.  Is this necessary?  
And how could I implement it in one module?
Sorry if this sounds confusing, but I'm pretty confused, and  
hoping  for enlightenment from the wizzards.

All best
Thomas
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


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



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


Re: [NTG-context] processing of setvariables/getvariables again

2005-10-21 Thread Taco Hoekwater



Thomas A. Schmitz wrote:

Hi Taco,

thanks for your reply!! I have to catch a train now, but I'll try  your 
suggestion tonight when I'm back. And yes, having the  modulesomething 
variables would be great.


What does \appendtoks do?


It appends stuff to token registers (like \everystarttext)

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


Re: [NTG-context] processing of setvariables/getvariables again

2005-10-21 Thread Thomas A. Schmitz

Taco,

I tried your suggestion, but I'm not sure I'm doing it the right way.  
I took the definition of \initialize... like so:


\def\initializegreekfont%
{\getvariable{Greek}{font}}
   \appendtoks \initializegreekfont \to \everystarttext % I guess I  
will need a similar procedure for
%  
initializegreekscale later


I will need the variable twice: once for selecting the typescript and  
defining the bodyfont. So in the typescriptfile with the definitions  
for all the fonts, I have these lines:


\starttypescript[Greek]
\definetypeface [My\initializegreekfont] [rm] [serif]  
[\initializegreekfont] [default] [encoding=agr]

\stoptypescript

And once more for switching to this font:

\startsetups[enablegreek]
   \catcode`~=\other
   \catcode`|=\other
   \catcode`'=\other
   \language[greek]
   \switchtobodyfont[My\initializegreekfont]
\stopsetups  %% suggested by Hans

\def\localgreek{\rescanwithsetup{enablegreek}}

I don't get any errors, but the font is not switched...

Any obvious mistakes I'm making?

Best

Thomas


On Oct 21, 2005, at 11:16 AM, Taco Hoekwater wrote:




Thomas A. Schmitz wrote:


Hi Taco,
thanks for your reply!! I have to catch a train now, but I'll try   
your suggestion tonight when I'm back. And yes, having the   
modulesomething variables would be great.

What does \appendtoks do?



It appends stuff to token registers (like \everystarttext)

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



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


[NTG-context] processing of setvariables/getvariables again

2005-10-20 Thread Thomas A. Schmitz

Hi all,

excuse me for being so pig-headed, but I'm running into the same  
problem I had two weeks ago. Peter Rolf was incredibly helpful, but I  
couldnt get things working. It is more a problem of architecture and  
general choices, IMHO, than of actual code. I tried every single part  
of what I want to achieve, and it works. The difficulty lies in  
getting the variables to work...


Basic problem: I want to refine my greek module. It provides a command

\setupgreek[font=,scale=]

which sets variables fonts and scale in the namespace Greek. The  
command is defined in the module, so in order to use it, the module  
has to be read. BUT: I want to use the result [i.e. \getvariable 
{Greek}{font} and \getvariable{Greek}{scale}] within the module  
itself. Is this possible?


Details: I want to organize the fonts in a typescript to be more  
flexible. So the module first defines the setupcommand:


\def\setupgreek{\setvariables[Greek]}

then it calls the typescript

\usetypescriptfile[type-tasgreek]

where all the Greek fonts are defined in this form:

\starttypescript [serif] [GreekGentium] [agr]
  \definefontsynonym [Greekgentium-Roman] [genagr-GentiumAlt]   
[encoding=agr]
  \definefontsynonym [Greekgentium-Italic][genagr-GentiumAItI]  
[encoding=agr]

\stoptypescript

\starttypescript [serif] [GreekGentium] [name]
  \usetypescript[serif][fallback]
  \definefontsynonym [Serif]   [Greekgentium-Roman]
  \definefontsynonym [SerifItalic] [Greekgentium-Italic]
  \definefontsynonym [SerifBold]   [Serif]
  \definefontsynonym [SerifBoldItalic] [Serif]
\stoptypescript

So the module calls the typescriptfile (or would it be more elegant  
to include these typescripts in the module itself?)


I then have the definition for the command \localgreek which  
contains, among other things, a call of the Greek font. I had been  
planning to implement it in this form:


\definetypeface [My\getvariable{Greek}{font}] [rm] [serif]  
[\getvariable{Greek}{font}] [default] [rscale = \getvariable{Greek} 
{font},encoding=agr]


and then, in the setups for \localgreek,

\switchtobodyfont[My\getvariable{Greek}{font}]

And that's where I'm banging my head against the wall: the module  
would be used like this


\usemodule[t-greek]
\setupgreek[font=GreekGentium,scale=0.9]

Which means: the entire module will be read BEFORE the \setupgreek  
command. But I would need the values of the setupgreek command WITHIN  
the module. Is that possible at all? Would I have to call a third  
file where the values are then processed? I tried to look into the  
source how \setup commands work, but I do get the impression that  
collecting the values and processing them is done in different files.  
Is this necessary? And how could I implement it in one module?


Sorry if this sounds confusing, but I'm pretty confused, and hoping  
for enlightenment from the wizzards.


All best

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