Re: [NTG-context] \processassignmentlist inside a \setup... or related
On 4/20/2021 1:28 PM, Jairo A. del Rio wrote: Oh, that's nice, but the \setupsomething part is still missing, i.e. I still want to be able to invoke \somethingparameter{...}. My question is about merging two tasks in one in a better way than the one I proposed, if possible. Thanks for the help. \def\mystuff[#1]% {\getdummyparameters{#1]% \RegisterMyDataA[#1]} 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 : 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 ___
Re: [NTG-context] \processassignmentlist inside a \setup... or related
Oh, that's nice, but the \setupsomething part is still missing, i.e. I still want to be able to invoke \somethingparameter{...}. My question is about merging two tasks in one in a better way than the one I proposed, if possible. Thanks for the help. Jairo El mar, 20 de abr. de 2021 a la(s) 02:00, Hans Hagen (j.ha...@xs4all.nl) escribió: > 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 > - > ___ 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 ___
Re: [NTG-context] \processassignmentlist inside a \setup... or related
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 - ___ 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 ___