\newconditional and Lua
Hi Hans, is there a simple way to change the status from commands created with \newconditional id \newif from, e.g. in the following example it’s easy to pass the value of the conditional from TeX to Lua but not in the reverse way. \newconditional\test \starttext \settrue\test TeX: \ifconditional\test TRUE\else FALSE\fi Lua: \startluacode if \luaconditional\test then context("TRUE") else context("FALSE") end \stopluacode TeX: \ifconditional\test TRUE\else FALSE\fi \stoptext When i change \newconditional to \newcount it’s easy but not very elegant. \newcount\test \starttext \settrue\test TeX: \ifconditional\test TRUE\else FALSE\fi Lua: \startluacode if \luaconditional\test then context("TRUE") else context("FALSE") end tex.count['test'] = 1 ; \stopluacode TeX: \ifconditional\test TRUE\else FALSE\fi \stoptext Wolfgang
On 26-4-2011 4:08, Wolfgang Schuster wrote:
Hi Hans,
is there a simple way to change the status from commands created with \newconditional id \newif from, e.g. in the following example it’s easy to pass the value of the conditional from TeX to Lua but not in the reverse way.
if tex.conditionals.whatever ... (virtual table, maybe I'll change the namespace) there are also tex.constants and tex.modes Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Am 26.04.2011 um 16:15 schrieb Hans Hagen:
On 26-4-2011 4:08, Wolfgang Schuster wrote:
Hi Hans,
is there a simple way to change the status from commands created with \newconditional id \newif from, e.g. in the following example it’s easy to pass the value of the conditional from TeX to Lua but not in the reverse way.
if tex.conditionals.whatever ...
Is there also a lua version of \settrue and \setfalse or \…true and \…false (because i saw the “tex.ifs” metatable)? Wolfgang
On 26-4-2011 4:31, Wolfgang Schuster wrote:
Am 26.04.2011 um 16:15 schrieb Hans Hagen:
On 26-4-2011 4:08, Wolfgang Schuster wrote:
Hi Hans,
is there a simple way to change the status from commands created with \newconditional id \newif from, e.g. in the following example it’s easy to pass the value of the conditional from TeX to Lua but not in the reverse way.
if tex.conditionals.whatever ...
Is there also a lua version of \settrue and \setfalse or \…true and \…false (because i saw the “tex.ifs” metatable)?
we can add tex.settrue ... but I think that we should get rid of \if... as much as possible \starttext \newconditional\TestConditional \startluacode function tex.settrue(name) tex.count[name] = 0 end function tex.setfalse(name) tex.count[name] = 1 end -- tex.settrue("TestConditional") \stopluacode \ifconditional\TestConditional YES \else NOP \fi \stoptext I'll add the two definitions. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
Wolfgang Schuster