From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/43451 Path: news.gmane.org!not-for-mail From: "Thomas A. Schmitz" Newsgroups: gmane.comp.tex.context Subject: passing dimensions to metapost Date: Thu, 28 Aug 2008 00:07:44 +0200 Message-ID: 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 1219874972 7861 80.91.229.12 (27 Aug 2008 22:09:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Aug 2008 22:09:32 +0000 (UTC) To: mailing ConTeXt users list for Original-X-From: ntg-context-bounces@ntg.nl Thu Aug 28 00:10:25 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 1KYTDb-0007eq-IT for gctc-ntg-context-518@m.gmane.org; Thu, 28 Aug 2008 00:10:23 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id DA4431FD81; Thu, 28 Aug 2008 00:09: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 04195-01-4; Thu, 28 Aug 2008 00:08:31 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id C2F2F1FD19; Thu, 28 Aug 2008 00:08:30 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 6425C1FD19 for ; Thu, 28 Aug 2008 00:08:22 +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 03218-03-2 for ; Thu, 28 Aug 2008 00:07:45 +0200 (CEST) Original-Received: from mailout08.t-online.de (mailout08.t-online.de [194.25.134.20]) by ronja.ntg.nl (Postfix) with ESMTP id AA2B21FB8F for ; Thu, 28 Aug 2008 00:07:45 +0200 (CEST) Original-Received: from fwd32.aul.t-online.de by mailout08.sul.t-online.de with smtp id 1KYTB3-00086W-01; Thu, 28 Aug 2008 00:07:45 +0200 Original-Received: from [192.168.0.2] (bLQrVeZ-whC-Bd6M7EGd+ZXHozYXYhm2e4md7j2T7V9-JsKZXkji9JGR53+jIbVg4t@[87.178.101.212]) by fwd32.aul.t-online.de with esmtp id 1KYTB2-0yVJC40; Thu, 28 Aug 2008 00:07:44 +0200 X-Mailer: Apple Mail (2.926) X-ID: bLQrVeZ-whC-Bd6M7EGd+ZXHozYXYhm2e4md7j2T7V9-JsKZXkji9JGR53+jIbVg4t@t-dialin.net X-TOI-MSGID: 8f524893-1aa0-4dad-b4a2-4bad0b7c4099 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:43451 Archived-At: Hi all, cleaning up the code in my module, I run into a very interesting problem. I want to pass a user-defined value to Metapost. Until now, the value "scale" had to be numeric, and I used it like this: draw fullcircle scaled \MPvar{scale}mm and Metapost was happy, and I was too. Now Aditya made the reasonable suggestion that users should be allowed to input any dimension and not be restricted to "mm." Easy enough. However, I also want a fallback just in case they input a number, in that case, I want to fall back to mm as a default. So I tried (after Taco's excellent explanation on the wiki): \expandafter\processaction\expandafter[\CVERscale]% [\v!unknown=>{\doifdimensionelse% {\CVERscale}% {\setupMPvariables[CircleSomething][scale=\CVERscale]}% {\doifnumberelse% {\CVERscale}% {\newdimen\CIscale \global\CIscale=\CVERscale mm {\setupMPvariables[CircleSomething][scale=\the\CIscale]}}% {\setupMPvariables[CircleSomething][scale=10mm\relax]% \message{Please give a proper value for the "scale" argument!}}}}, \v!default=>{\setupMPvariables[CircleSomething][scale=10mm \relax]}] So what I want: first check if \CVERscale is a dimension; if it is, assign it to the "scale" parameter. If it isn't, check if it is a number; if this is the case, append the unit "mm" to it and put it into a dimension register. If it isn't a number either, make the value sufficiently absurd for the user to realize and write a message to the terminal. This is all fine and dandy and works, sort of: it works perfectly with dimensions, but when I try with a number as input, it doesn't fall back to the unit "mm," but to "pt," AFAICS. That's nice too, but I have no clue why, and I would prefer mm. If it helps, I can try to give you a minimal test file tomorrow, but maybe somebody spots what I'm doing wrong? (I tried both with mkii and mkiv, and always get the same result.) 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 ___________________________________________________________________________________