ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <wolfgang.schuster@gmail.com>
To: hajtmar@gyza.cz, mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Working with variables in MkIV (\ setvariables, \getparameters etc)
Date: Sun, 9 Sep 2012 14:44:28 +0200	[thread overview]
Message-ID: <5A759A83-CA23-4296-8947-CD0A9D69CEA6@gmail.com> (raw)
In-Reply-To: <504C83E6.9090105@gyza.cz>


Am 09.09.2012 um 13:56 schrieb Jaroslav Hajtmar <hajtmar@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
___________________________________________________________________________________


  reply	other threads:[~2012-09-09 12:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-09  8:42 Jaroslav Hajtmar
2012-09-09  9:35 ` Wolfgang Schuster
2012-09-09 10:35   ` Jaroslav Hajtmar
2012-09-09 10:45     ` Wolfgang Schuster
2012-09-09 11:56       ` Jaroslav Hajtmar
2012-09-09 12:44         ` Wolfgang Schuster [this message]
2012-09-09 13:11           ` Jaroslav Hajtmar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5A759A83-CA23-4296-8947-CD0A9D69CEA6@gmail.com \
    --to=wolfgang.schuster@gmail.com \
    --cc=hajtmar@gyza.cz \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).