1

I like to have separate .mp files to organize my Metapost projects. But I'm facing this error message when I try to input file within a macro File names can't appear within macros. Even with this very clear message I'm wondering if there is a solution to call input files in a macro ? (package, extension, Metafun, Metafont, little hack, etc. ?)

def init =
    input var.mp
    draw (0,A)--(10,B)--(20,C);
enddef;

beginfig(1);

init;

endfig;
end.

Thank you for your help.

2

You can use readfrom:

string rf;
def init =
  forever:
    rf:=readfrom "var.mp";
    exitif rf=EOF;
    scantokens(rf);
  endfor
  closefrom "var.mp";
  draw (0,A)--(10,B)--(20,C);
enddef;

beginfig(1);

init;

endfig;
end.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.