Hello,
thanks, -
On Wed, 05 Jan 2011 21:41:13 +0100, Wolfgang Schuster
Am 05.01.2011 um 20:22 schrieb Procházka Lukáš:
Hello,
I'd need to pass a variable to Ctx and to retrieve it inside a compiled document - via Ctx itself and also by Lua. Something like modes; but modes allow just to check whether they are on or off. I'd need something like this:
You can check modes in Lua:
context --arguments="size=small" --mode=print test.tex
And can I check a variable (argument) in Lua in a similar way? --- \starttext Print mode: \doifmodeelse{print}{yes}{no} \startluacode if tex.modes['print'] then context("Print mode is enabled") else context("Print mode is disabled") end -- Something like this: >> if tex.arguments['size'] == "small" then -- Or: 'tex.variables["size"] == "small"' -- Or: 'document.arguments["size"] == "small"' context("Small size") end -- \stopluacode \doifenvelse{size} {\processaction [\env{size}] [ small=>Small size, medium=>Medium size, big=>Big size, unknown=>Other size: \env{size}]} {No value “size”} \stoptext --- If the passed argument has a NUMBER value, should it be checked against a number value or a string - so what of the following should be right: context --arguments="size=1" test.tex if tex.arguments['size'] == "1" then ... Or: if tex.arguments['size'] == 1 then ... Best regards, Lukas -- Ing. Lukáš Procházka [mailto:LPr@pontex.cz] Pontex s. r. o. [mailto:pontex@pontex.cz] [http://www.pontex.cz] Bezová 1658 147 14 Praha 4 Tel: +420 244 062 238 Fax: +420 244 461 038