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:

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))
\def\docallf[#1][#2]{\ctxlua{userdata.f("#1"\ifsecondargument, "#2"\fi)}}

Cheers, Peter

Contact information: http://pmrb.free.fr/contact/

If your question is of interest to others as well, please add an entry to the 

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net

Reply via email to