From: Henning Hraban Ramm <texml@fiee.net>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Sending data from lua to context and back to lua
Date: Thu, 8 Feb 2018 16:26:16 +0100 [thread overview]
Message-ID: <F8160D73-7711-4634-9103-CEDB00EC43BB@fiee.net> (raw)
In-Reply-To: <20180208143401.34bgqz6ulcc27f5e@nan>
Am 2018-02-08 um 15:34 schrieb Rudolf Bahr <quasi@quasi.de>:
> 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()}}
Greetlings, Hraban
---
http://www.fiee.net
http://wiki.contextgarden.net
GPG Key ID 1C9B22FD
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2018-02-08 15:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 17:39 Rudolf Bahr
2018-02-08 5:51 ` Rudolf Bahr
2018-02-08 8:30 ` Thomas A. Schmitz
2018-02-08 14:34 ` Rudolf Bahr
2018-02-08 15:18 ` Thomas A. Schmitz
2018-02-08 15:25 ` Hans Hagen
2018-02-08 15:26 ` Henning Hraban Ramm [this message]
2018-02-08 16:28 ` Rudolf Bahr
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=F8160D73-7711-4634-9103-CEDB00EC43BB@fiee.net \
--to=texml@fiee.net \
--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).