I often need some debugging info to find out what is going on in my METAPOST
code (as I often do not have exact knowledge of what some things do).
MetaPost’s ‘show’ command has limited formatting functionality (e.g. I would
like to add a number as a string to a show message instead of putting it out as
number and let ‘show' make a lot of lines out of it).
I would like to instead use a lua function and I think I recall having seen
somewhere the use of a call like lua( ….) or lua.foo.bar() in a
MetaPost/MetaFun/LMTX example but I cannot find it anymore.
Is it possible to do a lua() call from within MetaPost within LMTX and if so,
what is the way to do it? This below is the state of my misguided attempts:
\startluacode
function warnWithLabelIfVerbose( str, ... )
texio.write_nl( str .. string.format(...))
end
\stopluacode
\startMPdefinitions{doublefun}
%def somefunction ( expr str, number) =
% lua.warnWithLabel( "LABEL: ", "%s %d", str, number);
%enddef;
\stopMPdefinitions
\startMPpage[instance=doublefun]
lua.texio.write_nl( "HELLO!"); % This works
%lua.texio.write( "HELLO!\%n"); % This doesn't
%string outs; outs := lua.string.format( "HELLO! \%s \%0.3f", "aap", 12.6);
%somefunction( "aap", 12.6);
\stopMPpage
Thx,
G
___________________________________________________________________________________
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
___________________________________________________________________________________