From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/40141 Path: news.gmane.org!not-for-mail From: Taco Hoekwater Newsgroups: gmane.comp.tex.context Subject: Re: mplib Date: Sun, 13 Apr 2008 12:31:15 +0200 Message-ID: <4801E0F3.5050805@elvenkind.com> References: <48012E01.7850.2AAF773@wwl.musensturm.de> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1208082701 12875 80.91.229.12 (13 Apr 2008 10:31:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 13 Apr 2008 10:31:41 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun Apr 13 12:32:15 2008 connect(): Connection refused Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1JkzVP-0005aA-6X for gctc-ntg-context-518@m.gmane.org; Sun, 13 Apr 2008 12:32:15 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id F00251FC01; Sun, 13 Apr 2008 12:31:33 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 20823-03-2; Sun, 13 Apr 2008 12:31:21 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 720921FB8C; Sun, 13 Apr 2008 12:31:21 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id AA55D1FB8C for ; Sun, 13 Apr 2008 12:31:20 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 19807-03-10 for ; Sun, 13 Apr 2008 12:31:15 +0200 (CEST) Original-Received: from smtp-vbr9.xs4all.nl (smtp-vbr9.xs4all.nl [194.109.24.29]) by ronja.ntg.nl (Postfix) with ESMTP id 64DA61FB49 for ; Sun, 13 Apr 2008 12:31:15 +0200 (CEST) Original-Received: from [10.10.0.6] (boo.demon.nl [82.161.175.147]) (authenticated bits=0) by smtp-vbr9.xs4all.nl (8.13.8/8.13.8) with ESMTP id m3DAVFvO021669 for ; Sun, 13 Apr 2008 12:31:15 +0200 (CEST) (envelope-from taco@elvenkind.com) User-Agent: Thunderbird 1.5.0.10 (X11/20070305) In-Reply-To: <48012E01.7850.2AAF773@wwl.musensturm.de> X-Virus-Scanned: by XS4ALL Virus Scanner X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.9 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 X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:40141 Archived-At: Wolfgang Werners-Lucchini wrote: > On 12 Apr 2008 at 9:39, ntg-context-request@ntg.nl wrote: > >>> \startlua >>> mp = mplib.new ( { >>> hash_size = 100000, >>> main_memory = 2000000, >>> param_size = 100000, >>> } ) >>> >>> if mp then >>> res = mp:execute( >>> "beginfig(1) draw (0,0) .. (1,1) .. (2,1); endfig; bye;" ) >>> tex.print("[" .. tostring(res.status) .. "]") >>> mp:finish() >>> end >>> \stoplua >> no format, so beginfig, draw etc are unknown > > I thought 'plain.mem' is the default. But I see, there exists only > 'metafun.mem'. If you want to "do the low-level thing", you have to read the luatex manual carefully. MPlib is just like standalone metapost in that it wants to load a mem file in non-ini mode, and that file has to be generated before being used. Here is what you wanted to do, using just the library core (I did cheat just a little bit though, I added "dump;" at the end of my plain.mp): % start low-level \startlua local function finder(name, mode, ftype) if mode=="w" then return name else return kpse.find_file(name,ftype) end end mp = mplib.new ( { hash_size = 100000, main_memory = 2000000, param_size = 100000, find_file = finder, ini_version = true } ) if mp then res = mp:execute('plain') mp:finish() end mp = mplib.new ( { hash_size = 100000, main_memory = 2000000, param_size = 100000, find_file = finder, } ) if mp then res = mp:execute("\\beginfig(1) draw (0,0) .. (1,1) .. (2,1); endfig; bye;" ) tex.print("[" .. tostring(res.status) .. "]") mp:finish() end \stoplua % stop low-level If you just want to run plain metapost images inside of a context document (instead of metafun), it is much easier to use Hans' high-level API (once again, you need "dump;" at the end of plain.mp): \startlua metapost.process( metapost.format("plain"), "beginfig(0); draw (0,0) .. (1,1) .. (2,1); endfig;") \stoplua This makes sure that all memory values are the same, that the mem file is cached inbetween runs, removes the need for "\\" and "bye;" etc. 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________