From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/62077 Path: news.gmane.org!not-for-mail From: =?iso-8859-2?B?UHJvY2jhemthIEx1a+G5?= Newsgroups: gmane.comp.tex.context Subject: Calling Lua function from an external package Date: Wed, 29 Sep 2010 15:02:02 +0200 Message-ID: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=----------sNrpiwhq441JFpeZVr5to4 X-Trace: dough.gmane.org 1285765400 28620 80.91.229.12 (29 Sep 2010 13:03:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 29 Sep 2010 13:03:20 +0000 (UTC) To: ConTeXt Original-X-From: ntg-context-bounces@ntg.nl Wed Sep 29 15:03:18 2010 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P0wJZ-00073O-HD for gctc-ntg-context-518@m.gmane.org; Wed, 29 Sep 2010 15:03:17 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 01B73CA749; Wed, 29 Sep 2010 15:03:17 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id q0ntDCBRZT6h; Wed, 29 Sep 2010 15:03:11 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 089ECCA6D1; Wed, 29 Sep 2010 15:03:11 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 17FFBCA6D1 for ; Wed, 29 Sep 2010 15:03:10 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ZWexqkI0Kotz for ; Wed, 29 Sep 2010 15:03:03 +0200 (CEST) Original-Received: from filter3-ams.mf.surf.net (filter3-ams.mf.surf.net [192.87.102.71]) by balder.ntg.nl (Postfix) with ESMTP id 14006CA69E for ; Wed, 29 Sep 2010 15:03:03 +0200 (CEST) Original-Received: from mail.pontex.cz (mail.pontex.cz [89.233.168.98]) by filter3-ams.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id o8TD31Eq004207 for ; Wed, 29 Sep 2010 15:03:02 +0200 Original-Received: from lk-2008-nbk ([85.161.151.235]) (authenticated user lpr@pontex.cz) by mail.pontex.cz (Kerio MailServer 6.6.2) for ntg-context@ntg.nl; Wed, 29 Sep 2010 15:02:52 +0200 X-KWF-FilterProgress: * User-Agent: Opera Mail/10.10 (Win32) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=89.233.168.98; country=CZ; region=52; city=Prague; latitude=50.0833; longitude=14.4667; http://maps.google.com/maps?q=50.0833,14.4667&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0cDcB3216 - e5fd8e36c113 - 20100929 X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.71 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:62077 Archived-At: ------------sNrpiwhq441JFpeZVr5to4 Content-Type: text/plain; charset=iso-8859-2; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit 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. addto draw->addto .currentpicture.if.picture(EXPR0):also(EXPR0)else:doublepath(EXPR... ; <*> 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. addto draw->addto .currentpicture.if.picture(EXPR0):also(EXPR0)else:doublepath(EXPR... ; <*> 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() ...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 ------------sNrpiwhq441JFpeZVr5to4 Content-Disposition: attachment; filename=T~.lua Content-Type: application/octet-stream; name=T~.lua Content-Transfer-Encoding: Base64 ZnVuY3Rpb24gRjIoKQ0KICBjb250ZXh0KCJkcmF3ICgwLDApLS0oNWNtLDApIikN CmVuZA0KDQpwcmludCgiVH5PSyEiKQ0K ------------sNrpiwhq441JFpeZVr5to4 Content-Disposition: attachment; filename=MP-02.ctx Content-Type: application/octet-stream; name=MP-02.ctx Content-Transfer-Encoding: Base64 XHN0YXJ0dGV4dA0KICBBQUENCg0KICBcc3RhcnRsdWFjb2RlDQogICAgZnVuY3Rp b24gRigpDQogICAgICBjb250ZXh0KCJkcmF3ICgwLDApLS0oMmNtLDApIikNCiAg ICBlbmQNCg0KICAgIHJlcXVpcmUoIlR+IikNCg0KICAgIGNvbnRleHQuc3RhcnRN UGNvZGUoKQ0KICAgIEYoKQ0KICAgIEYyKCkNCiAgICBjb250ZXh0LnN0b3BNUGNv ZGUoKQ0KICBcc3RvcGx1YWNvZGUNClxzdG9wdGV4dA0K ------------sNrpiwhq441JFpeZVr5to4 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ ------------sNrpiwhq441JFpeZVr5to4--