30 Mar
2010
30 Mar
'10
6:30 p.m.
On Tue, Mar 30 2010, Hans van der Meer wrote:
called through: \def\callf#1#2{\ctxlua{f("#1","#2")}}
and do this actually with one argument: \callf{one}
then I find that the absent argument b in f(a,b) is not nil but a string of length 1.
Hello Hans, You want probably something like this: \startluacode userdata = userdata or {} function userdata.f(a, b) b = b or "default value" tex.print(string.format("a = '%s' and b = '%s'\\par", a, b)) end \stopluacode \def\callf{\dodoubleempty\docallf} \def\docallf[#1][#2]{\ctxlua{userdata.f("#1"\ifsecondargument, "#2"\fi)}} \starttext \callf[one] \callf[one][two] \callf[one][] \callf[][] \callf[][two] \callf[] \stoptext Cheers, Peter -- Contact information: http://pmrb.free.fr/contact/