On 4/20/2021 4:23 AM, Jairo A. del Rio wrote:
Hi, list! I hope my example shows clearly enough what I intend to do:
\startluacode
userdata = userdata or {}
userdata.mydata = {}
local function registermydata(data,...)
table.insert(userdata.mydata, data)
end
interfaces.implement{
name = "registermydata",
arguments = "2 strings",
actions = registermydata
}
\stopluacode
\unprotect
\def\mysetups[#1]%
{\getdummyparameters[#1]%
\processassignmentlist[#1]\clf_registermydata}
\protect
\starttext
\mysetups[love=nice,hate=awful]%
\dummyparameter{love}
\cldcontext{userdata.mydata[2]}
\stoptext
What I want to know is if there's a less hackish way to pass keys (yep, only keys, not values) to Lua using \getdummyparameters (actually I'm using an user-defined \setupsomething, but it's more or less the same) and \processassignmentlist. Is it possible, for instance, to automatically pass a key to Lua when it's set in \setupsomething? Thanks in advance.
Jairo
PS: Sorry if I missed something in the test suite again It's probably somewhere ...
\startluacode userdata = userdata or { } userdata.mydataA = { } userdata.mydataB = { } interfaces.implement { name = "RegisterMyDataA", public = true, arguments = { "hash" }, actions = function(t) for k, v in pairs(t) do table.insert(userdata.mydataA,k) end end, } interfaces.implement { name = "RegisterMyDataB", public = true, arguments = { "array" }, actions = function(t) for k, v in ipairs(t) do table.insert(userdata.mydataB,string.split(v,"=")[1]) end end, } \stopluacode \unprotect \protect \starttext \RegisterMyDataA[love=nice,hate=awful]% \RegisterMyDataB[love=nice,hate=awful]% \cldcontext{userdata.mydataA[2]} % unordered \cldcontext{userdata.mydataB[1]} % ordered \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------