This code compiles fine with plain MetaPost. input graph; beginfig(0); draw begingraph(1in,1in); setrange((0,0),(1,1)); for n=auto.x: show format("%g",n); endfor; endgraph; endfig; end However, this "ConTeXt translated" version errors in MKIV \usemodule[graph] \ctxlua{metapost.showlog=true} \startMPpage draw begingraph(1in,1in); setrange((0,0),(1,1)); for n=auto.x: show format("%g",n); endfor; endgraph; \stopMPpage See foo.log (attached). Thoughts? Troy
For the record, I'm not actually trying to "show" the picture that is returned by the format() function, but instead I want to assign the value of this picture to a variable, and it is erroring with that as well. Troy
Sorry for the flood. After some digging around it seems like the % should now be replaced by @. That is, I should use format("@g",n) Troy
Is the sarith package usable in MKIV? For example, I would like to get the numerical (not string) values of auto.x and auto.y from the graph package. I expect the following example to work, but it does not (even if I "input sarith") with MPinclusions. \usemodule[graph] \ctxlua{metapost.showlog=true} \startMPpage draw begingraph(1in,1in); setrange((0,0),(1,1)); for n=auto.x: show Scvnum n; % This is the line that is failing endfor; endgraph; \stopMPpage
Troy Henderson wrote:
Is the sarith package usable in MKIV? For example, I would like to get the numerical (not string) values of auto.x and auto.y from the graph package. I expect the following example to work, but it does not (even if I "input sarith") with MPinclusions.
This works: \startMPinclusions input graph; input sarith; \stopMPinclusions Apparently, an explicit input graph is needed as well. I have no idea why though, as there is an \startMPinclusions inside m-graph.mkiv too. Best wishes, Taco
Am 08.03.10 08:58, schrieb Taco Hoekwater:
Troy Henderson wrote:
Is the sarith package usable in MKIV? For example, I would like to get the numerical (not string) values of auto.x and auto.y from the graph package. I expect the following example to work, but it does not (even if I "input sarith") with MPinclusions.
This works:
\startMPinclusions input graph; input sarith; \stopMPinclusions
Apparently, an explicit input graph is needed as well. I have no idea why though, as there is an \startMPinclusions inside m-graph.mkiv too.
\startMPinclusions[+] input sarith; \stopMPinclusions Wolfgang
On Monday 08 March 2010 09:18:38 Wolfgang Schuster wrote:
\startMPinclusions[+] input sarith; \stopMPinclusions
This probably explains other problems that I had experienced concerning \startMPinclusions\stopMPinclusions... Indeed, as metapost is processed in one run under mkIV, I had gotten around such problems by simply putting certain metapost definitions in an early instance of \startMPcode\stopMPcode. Perhaps the [+] option could/should be by default for MPinclusions with some other option syntax allowing one to reinitialize the MPinclusions. Or maybe not... In any case, we need to document this more clearly. Concerning the graph package: 1) Should it use \startMPinclusions[+] so as not to erase other MPinclusions? 2) Is there a penalty/overhead in including sarith by default in the graph package? 3) Will metapost be able to better handle arithmetic soon, and/or can someone suggest a better way of using lua along with metapost graph? (Currently I externally use "awk" via \immediate\write18 to manipulate data.) Alan
On Mon, Mar 8, 2010 at 3:28 PM, Alan BRASLAU
(Currently I externally use "awk" via \immediate\write18 to manipulate data.) In mkiv you should be able to manipulate your data with lua & lpeg. You gain in portability -- no need of an external awk
-- luigi
On Monday 08 March 2010 15:35:14 luigi scarso wrote:
On Mon, Mar 8, 2010 at 3:28 PM, Alan BRASLAU
wrote: (Currently I externally use "awk" via \immediate\write18 to manipulate data.)
In mkiv you should be able to manipulate your data with lua & lpeg. You gain in portability -- no need of an external awk
Yes, another language to learn... (after all, I *like* awk) Can you indicate a good starting point? (perhaps this message should be filed under the thread on documentation...) Alan
participants (5)
-
Alan BRASLAU
-
luigi scarso
-
Taco Hoekwater
-
Troy Henderson
-
Wolfgang Schuster