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

Rudolf Bahr quasi at quasi.de
Sun Oct 6 07:11:29 CEST 2019


> A solution which uses only existing commands in the document.
> 
> \startsetups [martin]
>     \startlua
>         local points = tonumber(\getvariable{martin}{question}) or 0 ;
>               points = points * 92 ;
>         local answer = 42 ;
>         context.setvariable("martin","points",points) ;
>         context.setvariable("martin","answer",answer) ;
>     \stoplua
> \stopsetups
> 
> \setvariable{martin}{set}{\directsetup{martin}}
> 
> \starttext
> 
> \setvariables [martin] [question=44]
> 
> Points: \getvariable{martin}{points}
> 
> The answer is \getvariable{martin}{answer}.
> 
> \stoptext



Hello Wolfgang,

what exactly does the command
"\setvariable{martin}{set}{\directsetup{martin}}"?

I don't understand it. Has it something to do with "Command/datasetvariable"?
Especially what does "\directsetup"?

Rudolf


More information about the ntg-context mailing list