On 12/21/2013 12:50 PM, DesdeChaves wrote:

I know that metapost can send the variables "version", "number",
"string", "point", "quad", "boolean" and "path" to Context.
"triplet" variable can't pass. It will be very usefull if metapost can
send a array to context.

\startMPcode

numeric x[];
for i = 1 upto 10: x[i]:=random; endfor

passvariable("array",x);
     passvariable("version","1.0") ;
     passvariable("number",x[1]) ;
     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) ;


\stopMPcode

\ctxluacode{inspect(metapost.variables)}

\ctxcommand{mprunvar("array")}

Thanks in advance

that's less trivial (as automatism) so i provide passarrayvariable now (next beta) ... of course the next request would concern complex arrays so i also made a more low level flusher

\starttext

\startMPcode
    numeric n[]   ; for i=1 upto 10: n[i] := i + 1 ; endfor ;
path p[] ; for i=1 upto 10: p[i] := fullcircle scaled (i*cm) ; endfor ; numeric n[][] ; for i=1,4 : for j=1,3 : n[i][j] = uniformdeviate(1) ; endfor ; endfor ;

    passvariable("x",12345) ;
    passarrayvariable("n-array",n,1,7,1) ;
    passarrayvariable("p-array",p,1,7,1) ;
    passvariable("p",(1,1) .. (2,2)) ;

    % watch out: no ; in between

    startpassingvariable("b")
        startarray
            for i=1,4 :
                startarray
                    for j=1,3 :
                        value(n[i][j])
                    endfor
                stoparray
            endfor
        stoparray
    stoppassingvariable ;

    startpassingvariable("a")
        starthash
            key("test1")
                startarray
                    value(123)
                    value(456)
                stoparray
            key("test2")
                starthash
                    key("test")
                    value(789)
                stophash
        stophash
    stoppassingvariable ;

    draw fullcircle scaled 1cm ;
\stopMPcode

\ctxluacode{inspect(metapost.variables)}

\ctxcommand{mprunvar("x")}

\stoptext

-----------------------------------------------------------------
                                          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
___________________________________________________________________________________

Reply via email to