On 2/8/2018 3:34 PM, Rudolf Bahr wrote:
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.


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()"?
I have no clue what you want to achieve but Thomas means:



    context("Here is lua.")
context("I'm sending some picture names to Context in order to get back their sizes.")

    local imageA = "2007-01-01---Intro.png"
    local imageB = "2007-01-01---Neujahrsballade---1.png"
    local imageC = "2007-01-01---Neujahrsballade---2.png"

    local f = io.open("contextin.txt", "w")

\read15 to \zeileA
\read15 to \zeileB
\read15 to \zeileC

Here is \CONTEXT\ and what I got from Lua:


Now I'm working ... and write my answers to a file for lua:

\zeileA\ width=3000pt height=2000pt
\zeileB\ width=1200pt height=900pt
\zeileC\ width=1600pt height=1200pt

\immediate\write7{\zeileA\ width=3000pt height=2000pt \\}
\immediate\write7{\zeileB\ width=1200pt height=900pt  \\}
\immediate\write7{\zeileC\ width=1600pt height=1200pt \\}

    context("Here is lua again and what I got back from Context:")


                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
If your question is of interest to others as well, please add an entry to the 

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

Reply via email to