[NTG-context] passing variables/data between context and lua

Wolfgang Schuster wolfgang.schuster.lists at gmail.com
Sun Oct 6 22:44:12 CEST 2019


Rudolf Bahr schrieb am 06.10.2019 um 07:11:
> Hello Wolfgang,
> what exactly does the command
> "\setvariable{martin}{set}{\directsetup{martin}}"?
Let's start with a simple example where I set a values with the 
\setvariables command.

\setvariables
   [metadata]
   [author=Rudolf Bahr,
    date=\currentdate]

\starttext

\getvariable{metadata}{author}\par
\getvariable{metadata}{date}

\stoptext

The main point of the command is that you can choose whatever name you 
want for the keys to store the values.

Instead a using a list of values to store in a key-value-method you can 
also pass values to single keys with the \setvariable command, e.g. 
\setvariable{metatdata}{author}{Rudolf Bahr}.

While it is true that you're free to choose the name for the keys there 
are two keys with a special meaning, these two keys are "reset" and 
"set". The value of the "reset" key is used before the values in 
\setvariables are stored while "set" is used after the values are stored.
> I don't understand it. Has it something to do with "Command/datasetvariable"?
No, this is a different mechanism to save values between different 
ConTeXt runs which allows one to access values before they are set.
> Especially what does "\directsetup"?
When you access the content of a setups-environment you can use the 
\setups command (with a trailing s) to pass a list of setups or the 
\setup command, both commands allow you to use braces or brackets as 
delimiters for the argument. The \directsetup skips the check for the 
argument form and allows only braces as delimiter.

\startsetups[example-1]
     \startparagraph
         First example!
     \stopparagraph
\stopsetups

\startsetups[example-2]
     \startparagraph
         Second example!
     \stopparagraph
\stopsetups

\starttext

\setups[example-1,example-2]

\blank

\setups{example-1,example-2}

\blank

\setup[example-1]
\setup[example-2]

\blank

\setup{example-1}
\setup{example-2}

\blank

\directsetup{example-1}
\directsetup{example-2}

\stoptext

Wolfgang



More information about the ntg-context mailing list