From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/43459 Path: news.gmane.org!not-for-mail From: "Thomas A. Schmitz" Newsgroups: gmane.comp.tex.context Subject: Re: passing dimensions to metapost Date: Thu, 28 Aug 2008 15:02:03 +0200 Message-ID: <6A9F5376-35B7-47EE-8D00-E6EB4D92B6A4@uni-bonn.de> References: <48B65781.7000408@wxs.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v926) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1219928716 9749 80.91.229.12 (28 Aug 2008 13:05:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 28 Aug 2008 13:05:16 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Aug 28 15:06:07 2008 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 1KYhBb-0002tW-Q3 for gctc-ntg-context-518@m.gmane.org; Thu, 28 Aug 2008 15:05:40 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 65E291FE36; Thu, 28 Aug 2008 15:04:12 +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 00978-03-18; Thu, 28 Aug 2008 15:03:18 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 8A8EA1FE1F; Thu, 28 Aug 2008 15:03:16 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 33C3C1FE1E for ; Thu, 28 Aug 2008 15:03:13 +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 02063-07-19 for ; Thu, 28 Aug 2008 15:02:38 +0200 (CEST) Original-Received: from mailout05.t-online.de (mailout05.t-online.de [194.25.134.82]) by ronja.ntg.nl (Postfix) with ESMTP id 1C2571FDEF for ; Thu, 28 Aug 2008 15:02:37 +0200 (CEST) Original-Received: from fwd34.aul.t-online.de by mailout05.sul.t-online.de with smtp id 1KYh93-0001fB-03; Thu, 28 Aug 2008 15:02:37 +0200 Original-Received: from [192.168.0.2] (SUTu0sZdghubDRr9lYsxTbGVr+6i9ykEsFyPumak9WyVFQJkpr4hmfCAGX3Z2ArwEM@[87.178.72.144]) by fwd34.aul.t-online.de with esmtp id 1KYh8V-0RuBiy0; Thu, 28 Aug 2008 15:02:03 +0200 In-Reply-To: <48B65781.7000408@wxs.nl> X-Mailer: Apple Mail (2.926) X-ID: SUTu0sZdghubDRr9lYsxTbGVr+6i9ykEsFyPumak9WyVFQJkpr4hmfCAGX3Z2ArwEM@t-dialin.net X-TOI-MSGID: 989b3f5f-675f-40ae-bb67-2c51b581fee1 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:43459 Archived-At: On Aug 28, 2008, at 9:45 AM, Hans Hagen wrote: Hans, thanks a lot for your reply. Amazing - the lua code is so simple that even I can understand it! I'm certain to use it later; for the time being, I want to remain compatible for mkii and XeTeX as well. > \startluacode > document.mymodule = document.mymodule or { } > > function document.mymodule.checkdimen(str) > return (str:find("%a%a$") and str) or (str .. "mm") > end > \stopluacode > > \ctxlua{document.mymodule.checkdimen("#1")} > > or more fancy: > > function document.mymodule.checkdimen(str) > if not str:find("%a%a$") then > str = str .. "mm" > ctx.writestatus("mymodule","you forgot a dimension unit, so I > made it up for you: %s",str) > end > return str > end > > for mkii you can use \doifdimensionelse (it reminds me to implement > that > in mkiv) Hey, I WAS using \doifdimensionelse and \doifnumberelse! :-) And it appears to be working in mkiv as well! I found out the error in my code (it was too complex, and I was overwriting a variable with the same name; it looks like Metapost assigns "sp" as default unit to \MPvar). Problem solved, but it took me half a day... All best Thomas ___________________________________________________________________________________ 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 ___________________________________________________________________________________