Hello Hans,
thanks for the quick response.
However, the answer to just use \ctxlua as it expands, doesn’t help with the
usage of the module m-json.mkxl (from the context distribution) which has all
the interfaces in:
\startluacode
...
\stopluacode
So the simple question is: Is there a possibility to check the value passed to
context by the \tablefield interface?
Or is it better to extend the module like this for example?
% first quick shot:
\startluacode
local field = utilities.json.field
interfaces.implement{
name = "tablefieldset",
actions = function(namespace, path, csname)
local data = field(namespace, path)
tex.sprint(string.format("\\gdef\\%s{%s}", csname, data))
end,
arguments = "3 arguments",
public = true,
protected = true,
}
\stopluacode
And then:
% in the loop: instead of \edef\Title{\jasonfield{}{}}
...
\tablefieldset{mglist}{records[\recurselevel].title}{Title} % creates a macro
\Titel
...
\Salutaion\space\ifempty\Title\else\Title~\fi\Firstname\space\Name
Btw. Nice and very responsive group …
Thanks.
Andreas
Am 13.02.2026 um 13:24 schrieb Hans Hagen via ntg-context <[email protected]>:
On 2/13/2026 11:20 AM, Andreas Hof via ntg-context wrote:
> \edef\compareVal{A}
> \edef\temp{\ctxlua{context("A")}}
> \ifx\temp\compareVal equal\else not equal\fi
> But in the following variants I always branch to the \else path:
> \edef\temp{\ctxluacode{context("A")}}
> \ifx\temp\compareVal equal\else not equal\fi
\meaningful\ctxluacode
shows that it is (1) protected and (2) does more
> \edef\temp{\startluacode context("A") \stopluacode}
> \ifx\temp\compareVal equal\else not equal\fi
idem
> \edef\temp{\startlua context("A") \stoplua}
> \ifx\temp\compareVal equal\else not equal\fi
idem
> The following mwe (files are also attached), shows one use case (address
> field in the letter)
so just use \ctxlua which expands
> I hope someone here, is able to help.
also, there is:
- helper:
\doifelsesomething{\temp}{not empty}{empty}
- primitive \ifempty (also takes {})
\Salutaion\space\ifempty\Title\else\Title\space\fi\Firstname\space\Name
\blank[small]
- primitive \iftok
\iftok{\ctxlua{context("A")}}{A}\else not \fi equal
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] /
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] /
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________