[dev-context] \newconditional and Lua

Hans Hagen pragma at wxs.nl
Tue Apr 26 17:15:15 CEST 2011


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


More information about the dev-context mailing list