* Calling Lua function from an external package
@ 2010-09-29 13:02 Procházka Lukáš
2010-09-29 13:10 ` Hans Hagen
0 siblings, 1 reply; 5+ messages in thread
From: Procházka Lukáš @ 2010-09-29 13:02 UTC (permalink / raw)
To: ConTeXt
[-- Attachment #1: Type: text/plain, Size: 4426 bytes --]
Hello,
I have the following problem.
Let's have T~.lua file which defines a function:
---
function F2()
context("draw (0,0)--(5cm,0)")
end
print("T~OK!")
---
Let's have MP-02.ctx ConTeXt source file:
---
\starttext
AAA
\startluacode
function F()
context("draw (0,0)--(2cm,0)")
end
require("T~")
context.startMPcode()
F()
-- F2()
context.stopMPcode()
\stopluacode
\stoptext
---
Such code works OK - produces .pdf with a text "AAA" and a horizontal line.
You can find the text "T~OK!" in the compilation log - that means T~.lua was successfully loaded.
When I remove comment marks in front of F2() (which is defined in T~.lua), so I get:
---
\starttext
AAA
\startluacode
function F()
context("draw (0,0)--(2cm,0)")
end
require("T~")
context.startMPcode()
F()
F2()
context.stopMPcode()
\stopluacode
\stoptext
---
the compilation to .pdf fails with the following error message:
---
MTXrun | run 1: luatex --fmt="c:/ConTeXt/tex/texmf-cache/luatex-cache/context/f53042fa2e1c106bc7e3383ec8c3a00c/formats/cont-en" --lua="c:/ConTeXt/tex/texmf-cache/luatex-cache/context/f53042fa2e1c106bc7e3383ec8c3a00c/formats/cont-en.lui" --backend=pdf "./MP
-02.ctx"This is LuaTeX, Version beta-0.63.0-2010090921 (rev 3873)
\write18 enabled.
(MP-02.ctx
jobcontrol > resuming randomizer with 0.40830713827937
ConTeXt ver: 2010.09.22 12:33 MKIV fmt: 2010.9.22 int: english/english
system : cont-new loaded
(c:/ConTeXt/tex/texmf-context/tex/context/base/cont-new.tex
systems : beware: some patches loaded from cont-new.tex
(c:/ConTeXt/tex/texmf-context/tex/context/base/cont-new.mkiv))
system : cont-fil loaded
(c:/ConTeXt/tex/texmf-context/tex/context/base/cont-fil.tex
loading : ConTeXt File Synonyms
)
system : cont-sys.rme loaded
(c:/ConTeXt/tex/texmf-context/tex/context/user/cont-sys.rme (c:/ConTeXt/tex/texmf-context/tex/context/base/type-def.mkiv) (c:/ConTeXt/tex/texmf-context/tex/context/base/type-lua.mkiv) (c:/ConTeXt/tex/texmf-context/tex/context/base/type-siz.mkiv) (c:/ConTeX
t/tex/texmf-context/tex/context/base/type-otf.mkiv))
system : cont-err loaded
(c:/ConTeXt/tex/texmf-context/tex/context/base/cont-err.tex
systems : no file 'cont-sys.tex', using 'cont-sys.rme' instead
)
system : MP-02.top loaded
(MP-02.top)
fonts : preloading latin modern fonts
{c:/ConTeXt/tex/texmf/fonts/map/dvips/lm/lm-math.map}{c:/ConTeXt/tex/texmf/fonts/map/dvips/lm/lm-rm.map}{c:/ConTeXt/tex/texmf-context/fonts/map/pdftex/context/mkiv-base.map}
bodyfont : 12pt rm is loaded
language : language en is active
publications : loading formatting style from bxml-apa
(c:/ConTeXt/tex/texmf-context/tex/context/base/bxml-apa.mkiv)
systems : begin file MP-02.ctx at line 1
T~OK!
mplib : initializing instance 'metafun' using format 'metafun'
mplib : loading 'metafun.mp' (experimental metapost version two)
! mp terminal: ! Extra tokens will be flushed.
<to be read again>
addto
draw->addto
.currentpicture.if.picture(EXPR0):also(EXPR0)else:doublepath(EXPR...
<to be read again>
;
<*> draw (0,0)--(2cm,0)draw (0,0)--(5cm,0);
.
system > error on line 4 in file MP-02.ctx: mp terminal: ! Extra tokens will be flushed.
<to be read again>
addto
draw->addto
.currentpicture.if.picture(EXPR0):also(EXPR0)else:doublepath(EXPR...
<to be read again>
;
<*> draw (0,0)--(2cm,0)draw (0,0)--(5cm,0);
...
1 \starttext
2 AAA
3
4 >> \startluacode
5 function F()
6 context("draw (0,0)--(2cm,0)")
7 end
8
9 require("T~")
10
11 context.startMPcode()
12 F()
13 F2()
14 context.stopMPcode()
<inserted text> ...re.mp ; fi ; ;;;;]===], false)}
\processMPgraphic ...e ;\!!es , \MPaskedfigure )}}
\egroup \placeMPgraphic \d...
l.4 \stopMPcode
} context.stopMPcode()
\dodostartluacode ...d \directlua \zerocount {#1}}
l.15 \stopluacode
---
It's strange to me, especially when body of F() and F2() is almost identical.
Why? And how do I make it work (I mean still having a function defined in a separate file)?
Thank you in advance.
Cheers,
Lukas
[-- Attachment #2: T~.lua --]
[-- Type: application/octet-stream, Size: 72 bytes --]
function F2()
context("draw (0,0)--(5cm,0)")
end
print("T~OK!")
[-- Attachment #3: MP-02.ctx --]
[-- Type: application/octet-stream, Size: 225 bytes --]
\starttext
AAA
\startluacode
function F()
context("draw (0,0)--(2cm,0)")
end
require("T~")
context.startMPcode()
F()
F2()
context.stopMPcode()
\stopluacode
\stoptext
[-- Attachment #4: Type: text/plain, Size: 486 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Calling Lua function from an external package
2010-09-29 13:02 Calling Lua function from an external package Procházka Lukáš
@ 2010-09-29 13:10 ` Hans Hagen
2010-09-29 13:27 ` Taco Hoekwater
0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2010-09-29 13:10 UTC (permalink / raw)
To: mailing list for ConTeXt users
On 29-9-2010 3:02, Procházka Lukáš wrote:
> Hello,
>
> I have the following problem.
>
> Let's have T~.lua file which defines a function:
hm, what is this ~ doing there ... avoid such characters! ~ is HOME on
some systems
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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Calling Lua function from an external package
2010-09-29 13:10 ` Hans Hagen
@ 2010-09-29 13:27 ` Taco Hoekwater
2010-09-29 13:35 ` Procházka Lukáš Ing. - Pontex s. r. o.
0 siblings, 1 reply; 5+ messages in thread
From: Taco Hoekwater @ 2010-09-29 13:27 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Hans Hagen
On 09/29/10 15:10, Hans Hagen wrote:
> On 29-9-2010 3:02, Procházka Lukáš wrote:
>> Hello,
>>
>> I have the following problem.
>>
>> Let's have T~.lua file which defines a function:
>
> hm, what is this ~ doing there ... avoid such characters! ~ is HOME on
> some systems
That is true of course, but the problem is much simpler than that:
Make sure you end your metapost expressions with a semicolon.
Best wishes,
Taco
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Calling Lua function from an external package
2010-09-29 13:27 ` Taco Hoekwater
@ 2010-09-29 13:35 ` Procházka Lukáš Ing. - Pontex s. r. o.
2010-09-29 13:48 ` Stefan Müller
0 siblings, 1 reply; 5+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2010-09-29 13:35 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Hans Hagen
... Thanks, it works now! It had to be fixed both in F() and in F2().
(I forgot ";" in MP statement as Lua doesn't require ";".)
(Still it's a bit strange to me that calling F() worked even when the MP statement in F() was not finished by ";" and F2() was not called.)
Lukas
On Wed, 29 Sep 2010 15:27:14 +0200, Taco Hoekwater <taco@elvenkind.com> wrote:
>
>
> On 09/29/10 15:10, Hans Hagen wrote:
>> On 29-9-2010 3:02, Procházka Lukáš wrote:
>>> Hello,
>>>
>>> I have the following problem.
>>>
>>> Let's have T~.lua file which defines a function:
>>
>> hm, what is this ~ doing there ... avoid such characters! ~ is HOME on
>> some systems
>
> That is true of course, but the problem is much simpler than that:
>
> Make sure you end your metapost expressions with a semicolon.
>
> Best wishes,
> Taco
>
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> 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
> ___________________________________________________________________________________
>
--
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o. [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4
Tel: +420 244 062 238
Fax: +420 244 461 038
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Calling Lua function from an external package
2010-09-29 13:35 ` Procházka Lukáš Ing. - Pontex s. r. o.
@ 2010-09-29 13:48 ` Stefan Müller
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Müller @ 2010-09-29 13:48 UTC (permalink / raw)
To: ntg-context
I think that ";" is not needed to end an MP statement but to separate
two of them. So it works without as long as you only have one MP statement.
Stefan
On 29.09.2010 15:35, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
> ... Thanks, it works now! It had to be fixed both in F() and in F2().
>
> (I forgot ";" in MP statement as Lua doesn't require ";".)
>
> (Still it's a bit strange to me that calling F() worked even when the MP
> statement in F() was not finished by ";" and F2() was not called.)
>
> Lukas
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-09-29 13:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-29 13:02 Calling Lua function from an external package Procházka Lukáš
2010-09-29 13:10 ` Hans Hagen
2010-09-29 13:27 ` Taco Hoekwater
2010-09-29 13:35 ` Procházka Lukáš Ing. - Pontex s. r. o.
2010-09-29 13:48 ` Stefan Müller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).