From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/31082 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: run a ruby script and use the standard output ??? Date: Thu, 28 Sep 2006 09:45:29 +0200 Message-ID: <451B7D99.20902@wxs.nl> References: <451AE846.2090701@nibua-r.org> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1159429557 10765 80.91.229.2 (28 Sep 2006 07:45:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 28 Sep 2006 07:45:57 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Thu Sep 28 09:45:55 2006 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 ciao.gmane.org with esmtp (Exim 4.43) id 1GSqaU-0002La-OK for gctc-ntg-context-518@m.gmane.org; Thu, 28 Sep 2006 09:45:44 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 5B7731FF33; Thu, 28 Sep 2006 09:45:42 +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 25725-04-4; Thu, 28 Sep 2006 09:45:36 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 38BF51FF13; Thu, 28 Sep 2006 09:45:36 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id D4B551FF13 for ; Thu, 28 Sep 2006 09:45:32 +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 25725-04-3 for ; Thu, 28 Sep 2006 09:45:29 +0200 (CEST) Original-Received: from mail.pragma-ade.net (dsl-083-247-100-017.solcon.nl [83.247.100.17]) by ronja.ntg.nl (Postfix) with SMTP id 24DB41FE5C for ; Thu, 28 Sep 2006 09:45:29 +0200 (CEST) Original-Received: from [10.100.1.104] (unverified [10.100.1.104]) by controller-1 (SurgeMail 3.7b8) with ESMTP id 10427 for ; Thu, 28 Sep 2006 09:45:29 +0200 User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) Original-To: mailing list for ConTeXt users In-Reply-To: <451AE846.2090701@nibua-r.org> X-Server: High Performance Mail Server - http://surgemail.com r=-274017400 X-Authenticated-User: hagen@controller-1 X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 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:31082 Archived-At: Renaud AUBIN wrote: > Hi all, > > Is it possible to run a ruby script from a context document during its > processing (I already know how to do that using \write18 but there is > maybe a better way...) then get the output of the script to display or > use it into the document. It's a little bit hard to describe so I have > a simple example: > > \starttext > \def\vartest{3.124325234543523452435} > \write18{ruby ./myscript.rb \vartest > XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX} > \stoptext > > with myscript.rb: > > temp = ARGV[0] > puts "\nXXXXXXXXXXXXX " + (Math::sqrt(temp.to_f)).to_s + " > XXXXXXXXXXXXX\n" > > I would store the result of puts into a variable usable within ConTeXt... > piping: the latest versions of pdftex support this (i\ve forgotten the syntax, but taco who wrote the patch may remember) you can also let ruby write a definition to a file temp.tmp which you can read in however, luatex can do: \edef\SomeVar{\lua{tex.print(math.sqrt(3.124325234543523452435))} or \def\GimmeARoot#1{\lua{tex.print(math.sqrt(#1))} actually, this is one of the examples i use in prelim demos at user group meetings -) so, be a bit patient and it will come your way ... Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------