[NTG-context] Lua code inside database module

Hans Hagen pragma at wxs.nl
Mon Jul 26 10:45:32 CEST 2010


On 26-7-2010 8:36, Jaroslav Hajtmar wrote:
> Hello all,
>
> Is there any possibility use Lua commands in
> \startseparatedlist[NaturalTable] ... \stopseparatedlist environment in
> database module?
> I would like using database module im my Lua application.
> Thanx
> Jaroslav
>
> Here is mimimal example:
>
> \usemodule[database]
>
> \defineseparatedlist
> [NaturalTable]
> [separator=comma,
> before=\bTABLE,after=\eTABLE,
> first=\bTR,last=\eTR,
> left=\bTD,right=\eTD]
>
>
> \starttext
>
> \startseparatedlist[NaturalTable]
> col1,col2,col3
> \stopseparatedlist
>
> \startseparatedlist[NaturalTable]
> \directlua{tex.print("col1,col2,col3")} % here program fails
> \stopseparatedlist
>
> \stoptext

you could expand the content

\expanded{\startseparatedlist[NaturalTable]
\ctxlua{tex.print("col1,col2,col3")}}
\stopseparatedlist

or use

\startluacode
context.startseparatedlist { "NaturalTable" }
tex.print("col1,col2,col3")
context.stopseparatedlist()
\stopluacode

of course you can also do all at the lua end (reminds me that I promised 
mojca to rewrite the database module)

-----------------------------------------------------------------
                                           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