[NTG-context] Problem calling Lua during \startsetups

Procházka Lukáš Ing. - Pontex s. r. o. LPr at pontex.cz
Tue Jan 25 08:33:02 CET 2011


Hello,

I encountered a bit weird thing when I used Lua in \startsetup:

---
\definelayer[T][x=0mm,y=0mm,width=\paperwidth,height=\paperheight]

\directlua{n, m = 1, 11} % Initialization

\startsetups layer
   % In my real code (= not in this example)
   % the value of 'n' is used here to set the appropriate background,
   % = n-th page of a PDF, and also to draw a filled rectangle on
   % the left or right side (depending on whether n is even or odd)

   % The code bellow fails [1]

   \startluacode
     print("N=", n)

     if n == 2 then
     else
     end
   \stopluacode
\stopsetups

\setupbackgrounds[page][setups=layer,background={T}]

\starttext
   % The code bellow works well [2]

   \startluacode
     print("M=", m)

     if m == 2 then
     else
     end
   \stopluacode

   \dorecurse{4}{\page[empty]}
\stoptext
---

The problem is that Lua code between \startsetups ... \stopsetups [1] seems to be "parsed" another way than when in [2].

The [1] gives the following error message:

---
! LuaTeX error <main ctx instance>:1: 'then' expected near 'thenelseend'.
---

So it seems like <space>s and/or <\n>s were "ignored".

If you commented [1], the section [2] would work well.

So how to use make Lua work well even between \startsetups ... \stopsetups?

Best regards,

Lukas


-- 
Ing. Lukáš Procházka [mailto:LPr at pontex.cz]
Pontex s. r. o.      [mailto:pontex at pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t-Bkg.log
Type: application/octet-stream
Size: 8183 bytes
Desc: not available
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20110125/c304d995/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t-Bkg.mkiv
Type: application/octet-stream
Size: 704 bytes
Desc: not available
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20110125/c304d995/attachment-0003.obj>


More information about the ntg-context mailing list