Pablo Rodriguez schrieb am 13.10.2020 um 17:33:
Dear list,
I have the following sample:
\starttext
\def\numbersfname
{\cldcontext{string.match([[\env{fname}]], "\letterpercent d+")}}
\ctxlua{ c = context.getvariable("environment", "fname") or "a" }
\ctxlua{ d = [[\env{fname}]] }
tex: \numbersfname\\
\doifelse{}
{123}{yes}{no}\\
c: \cldcontext{c}\\
\doifelse{\cldcontext{c:match("\letterpercent d+")}}
{123}{yes}{no}\\
d: \cldcontext{d}\\
\doifelse{\cldcontext{d:match("\letterpercent d+")}}
{123}{yes}{no}
\stoptext
For compilation, I run the command:
context --purgeall --arguments=fname={abc123} test-file.tex
These things are failing:
1. I don’t know how to get \numbersfname equal to "123". I don’t know
what I’m doing wrong.
2. Is there no Lua version of \getvariable{...}{...}?
There is no need because everything is stored in a Lua table.
%%%% begin example
\starttext
\startluacode
local argumentlist = document.arguments.arguments
local argumenttable = utilities.parsers.settings_to_hash(argumentlist)
context(argumenttable["fname"])
\stopluacode
\stoptext
%%%% end example
I tested the example with:
context --arguments="fname=abc123" <filename>
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
___________________________________________________________________________________