From: Alan BRASLAU <alan.braslau@cea.fr>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: pragma@wxs.nl
Subject: Re: new mp trickery / next challenge for alan and mari
Date: Tue, 10 Sep 2013 18:34:36 +0200 [thread overview]
Message-ID: <20130910183436.4050345b@iram-hb-003386.extra.cea.fr> (raw)
In-Reply-To: <522F44A1.9050304@wxs.nl>
Indeed a challenge!
Alan
On Tue, 10 Sep 2013 18:11:13 +0200
Hans Hagen <pragma@wxs.nl> wrote:
> Hi,
>
> There's now a convenient way to pass data back from an mprun to the
> tex instance:
>
> \starttext
>
> \startMPcode
> passvariable("version","1.0") ;
> passvariable("number",123) ;
> passvariable("string","whatever") ;
> passvariable("point",(1,2)) ;
> passvariable("triplet",(1,2,3)) ;
> passvariable("quad",(1,2,3,4)) ;
> passvariable("boolean",false) ;
> passvariable("path",fullcircle scaled 1cm) ;
>
> draw fullcircle scaled 20pt ;
> \stopMPcode
>
> \ctxlua{inspect(metapost.variables)}
>
> \ctxcommand{mprunvar("number")}
> \ctxcommand{mprunvar("string")}
>
> \stoptext
>
> the inspect shows:
>
> table={
> ["boolean"]=false,
> ["number"]=123,
> ["path"]={
> { 10.02177, 10.02177, 12.67969, 7.36386, 7.36386, 12.67969 },
> { 0, 14.17323, 3.75914, 14.17323, -3.75914, 14.17323 },
> { -10.02177, 10.02177, -7.36386, 12.67969, -12.67969, 7.36386 },
> { -14.17323, 0, -14.17323, 3.75914, -14.17323, -3.75914 },
> { -10.02177, -10.02177, -12.67969, -7.36386, -7.36386, -12.67969 },
> { 0, -14.17323, -3.75914, -14.17323, 3.75914, -14.17323 },
> { 10.02177, -10.02177, 7.36386, -12.67969, 12.67969, -7.36386 },
> { 14.17323, 0, 14.17323, -3.75914, 14.17323, 3.75914 },
> },
> ["point"]={ 1, 2 },
> ["quad"]={ 1, 2, 3, 4 },
> ["string"]="whatever",
> ["triplet"]={ 1, 2, 3 },
> ["version"]="1.0",
> }
>
> the mprunvar pips a value or concatination to tex
___________________________________________________________________________________
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
___________________________________________________________________________________
prev parent reply other threads:[~2013-09-10 16:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-10 16:11 Hans Hagen
2013-09-10 16:34 ` Alan BRASLAU [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130910183436.4050345b@iram-hb-003386.extra.cea.fr \
--to=alan.braslau@cea.fr \
--cc=ntg-context@ntg.nl \
--cc=pragma@wxs.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).