ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Martin Althoff <martin.althoff@yahoo.com>
To: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>,
	mailing list for ConTeXt users <ntg-context@ntg.nl>,
	mf <massifr@fastwebnet.it>
Subject: Re: passing variables/data between context and lua
Date: Sun, 29 Sep 2019 13:51:02 +0200	[thread overview]
Message-ID: <0d24efde3d1126ce61340fda2313521d530cc513.camel@yahoo.com> (raw)
In-Reply-To: <4c95d00f-b9fc-1595-eb62-ebe75e55439f@gmail.com>

Thanks for the quick answers. Both suggestions work for me. 

@Massi Thanks for the pointer into the cld-mkiv.pdf 

@Wolfgang: I have to admit that I don't completely comprehend your solution, though it
works. Searching around for the commands you use, I came across an older posting you
answered too:

https://mailman.ntg.nl/pipermail/ntg-context/2012/064326.html

That helps too. However I can find little documentation on the \setvariable/s commands.
I'll play around with the solution to understand it better. 




> \defineexpandable\question{44}

> 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
> 
> Wolfgang
> 

___________________________________________________________________________________
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
___________________________________________________________________________________

  parent reply	other threads:[~2019-09-29 11:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-27  4:59 Martin Althoff
2019-09-27  8:41 ` mf
2019-09-27 12:58 ` Wolfgang Schuster
2019-09-28  6:53   ` defs, variables and dimensions (was: passing variables/data between context and lua) Henning Hraban Ramm
2019-09-28 17:51     ` defs, variables and dimensions Wolfgang Schuster
2019-09-30  2:51     ` defs, variables and dimensions (was: passing variables/data between context and lua) Martin Althoff
2019-09-29 11:51   ` Martin Althoff [this message]
2019-10-06  5:11   ` passing variables/data between context and lua Rudolf Bahr
2019-10-06 20:44     ` Wolfgang Schuster
2019-10-08  7:21       ` Rudolf Bahr
2019-10-08 12:55         ` Aditya Mahajan
2019-10-08 16:22           ` 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=0d24efde3d1126ce61340fda2313521d530cc513.camel@yahoo.com \
    --to=martin.althoff@yahoo.com \
    --cc=massifr@fastwebnet.it \
    --cc=ntg-context@ntg.nl \
    --cc=wolfgang.schuster.lists@gmail.com \
    /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).