[NTG-context] Using lua to define a macro with one optional parameter in brackets

Hans Hagen pragma at wxs.nl
Wed Jul 8 20:54:25 CEST 2015


On 7/8/2015 4:11 PM, Jaroslav Hajtmar wrote:
> Thanks Taco very much.
>
> At this point, it really works in simple situations, but in the event
> that this solution will incorporate into the existing system, then I
> have big problems with expansion (values are not updated in macros). I
> need more solutions using something like context.setgvalue, or at least
> according to the following example. If they could incorporate the
> remaining two definitions
> ie
> \def\simpleA {content when parameter is missing}
> \def\complexA[#1]{parameter #1}
>
> into luacode (probably encounter a problem with #), so it might work.
> Can not think of anyone, how it could be done differently?
> Thanks Jaroslav Hajtmar
>
> Here is minimal example:
>
> \ctxlua{
> xlsname='A'
> content='content when parameter is missing'
> context([[\definecomplexorsimple\]]..xlsname)
> %context([[\def\simple]]..xlsname..[[{]]..content..[[}]])
> %context([[\def\complex]]..xlsname..'[#1]'..[[{Neco: #1}]])
> }
>
> \def\simpleA {content when parameter is missing}
> \def\complexA[#1]{parameter #1}

why don't you define these commands at the tex level

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list