![](https://secure.gravatar.com/avatar/5347b1604e2495e607f617fe6297b881.jpg?s=120&d=mm&r=g)
On Thu, Feb 08, 2018 at 04:26:16PM +0100, Henning Hraban Ramm wrote:
Am 2018-02-08 um 15:34 schrieb Rudolf Bahr
: On Thu, Feb 08, 2018 at 09:30:48AM +0100, Thomas A. Schmitz wrote:
On 02/07/2018 06:39 PM, Rudolf Bahr wrote:
Sometimes the necessity could arise to send data from lua to context and answers back to lua. I tried this by using "read" and "immediate\write" commands in context. These commands are described in chapter 21 and 22 of Donald E. Knuth's "The TeXbook".
My question is: Do there exist better and more simple solutions?
You can print (typeset) information from inside lua code with the "context" function. Have you seen the manual cld-mkiv.pdf? It's in the minimals.
Thomas
Yes, thank you. I tried "context()" several times, but without success. Could be, that I have a false meaning how to use it: If I transfer data from context to lua and vice versa then in my imagination there must be variables in both languages where the sent data is to be found.
With the use of "\immediate\write" and "\read" in context and the read and write functions in lua I know exactly from where to where the data goes. How to do the same with "context()"?
\startluacode
function SomeFunction() context("Value") end
\stopluacode
\def\MyVar{\ctxlua{SomeFunction()}}
YES! That's what I needed to get back data from lua to context! Many thanks to Hraban, Hans and Thomas for your help! Rudolf