ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* new mp trickery / next challenge for alan and mari
@ 2013-09-10 16:11 Hans Hagen
  2013-09-10 16:34 ` Alan BRASLAU
  0 siblings, 1 reply; 2+ messages in thread
From: Hans Hagen @ 2013-09-10 16:11 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: new mp trickery / next challenge for alan and mari
  2013-09-10 16:11 new mp trickery / next challenge for alan and mari Hans Hagen
@ 2013-09-10 16:34 ` Alan BRASLAU
  0 siblings, 0 replies; 2+ messages in thread
From: Alan BRASLAU @ 2013-09-10 16:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: pragma

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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-09-10 16:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-10 16:11 new mp trickery / next challenge for alan and mari Hans Hagen
2013-09-10 16:34 ` Alan BRASLAU

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).