This worked when I was just doing METAPOST. Now, I am using my lua code to produce the METAPOST code that produces the pictures. And the picture itself is put in a file for METAPOST as follows:

File test4-mplib-run-001.mp:

% begin graphic: n=0

; beginfig(1) ; defaultfont:="name:dejavuserif*default"; CurrentLayout:="article"; def OverlayLineColor=black enddef; def OverlayColor =black enddef; ;picture pic; x:=80.000; y:=200.000; w:=133.000; h:=53.000;pic := ApplicationComponentLogo( w, h, typeString) shifted (x, -y); draw pic;picture pic; x:=273.000; y:=253.000; w:=133.000; h:=53.000;pic := Function( w, h, typeString) shifted (x, -y); draw pic;picture pic; x:=380.000; y:=133.000; w:=133.000; h:=53.000;pic := Service( w, h, typeString) shifted (x, -y); draw pic;path p; p := (200.000,-227.000)--(333.000,-227.000)--(333.000,-273.000); draw p;path p; p := (393.000,-253.000)--(393.000,-180.000); draw p;;; endfig ;
% end graphic

This apparently is tried to get run through METAPOST separately and that clearly doesn’t work, because ApplicationComponentLogo isn’t defined. This is the result of the following setup:

\starttext
\startMPdefinitions (or inclusions, no difference)
% ApplicationComponentLogo is defined here with a vardef
\stopMPdefinitions
\ctxlua{foo(“filename”)} % produces a series of
%    context.startMPpage { instance = "doublefun” }
%    several of:
% context( METAPOST statements in a string)
%    context.stopMPpage()
\stoptext

How do I get my MPdefinitions available in those METAPOST runs?

G

On 13 Mar 2020, at 14:59, Hans Hagen <j.hagen@xs4all.nl> wrote:

On 3/13/2020 2:33 PM, Aditya Mahajan wrote:
On Fri, 13 Mar 2020, Taco Hoekwater wrote:
Hi,



On 13 Mar 2020, at 12:53, Gerben Wierda <Gerben.Wierda@rna.nl> wrote:

Suppose I have this code:


Can I reuse that varied across follow-up MPPages?

Sure, put the vardef inside \startMPinclusions:
or \startMPdefinitions ... \stopMPdefinitions (don't remember what is the difference between inclusions and definitions, now).
definitions: once
inclusions : every time

-----------------------------------------------------------------
                                         Hans Hagen | PRAGMA ADE
             Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________