Re: Problem with showing paths
Laurence Finston <[email protected]> Fri, 21 Jan 2022 12:13:31 +0100
| Newsgroups | gmane.comp.tex.metapost |
|---|---|
| Message-ID | <trinity-779934f5-208a-4ef6-8027-dcf2278d8861-1642763611172@3c-app-gmx-bs26> |
> Since I'm writing the command to a pipe, there's no need for a file [...] Sorry, I got confused here. Of course, "write" writes to a file and I changed this accordingly in my C++ code. On the other hand, I could use a named pipe (a.k.a. "fifo") and I probably will, so as not to have to delete the file, which doesn't need to be kept. Gesendet: Freitag, 21. Januar 2022 um 11:18 Uhr Von: "Laurence Finston" <[email protected]> An: "luigi scarso" <[email protected]> Cc: "MetaPost List" <[email protected]> Betreff: Aw: Re: [metapost] Problem with showing paths > not with "double" but with "decimal" and "binary" we have numberprecision: > [...]: > decimal and binary are slower than double, btw. Thanks. decimal or binary should do it. Speed isn't an issue. > I think this is the right way, not a workaround: write your data to a file , post-process the file with, for example, perl. Since I'm writing the command to a pipe, there's no need for a file and I'm using Flex. Under other circumstances I would use gawk, but there are any number of ways of solving this problem. I make all of this sort of thing available anyway, but it might be useful for others with similar problems to see this example (when it's finished). I'm not sure how they would find out about it, though. At any rate, the code for the scanning function is here: https://git.savannah.gnu.org/cgit/3dldf.git/tree/src/scnmptpt.web It doesn't work yet, but should in the next day or two. The file with the macros (only the one so far) is here: https://git.savannah.gnu.org/cgit/3dldf.git/tree/src/writemcs.mp I will be adding at least a macro for numerics and possibly ones for other data types. I may just use Werner's solution for increasing the line length. However, if there's no guarantee that the format of the output of "show" won't change, it may be safer to use the macro. In addition, I can avoid skipping over the strings MP writes to its output that I don't need. Gesendet: Freitag, 21. Januar 2022 um 09:20 Uhr Von: "luigi scarso" <[email protected]> An: Kein Empfänger Cc: "MetaPost List" <[email protected]> Betreff: Re: [metapost] Problem with showing paths On Fri, Jan 21, 2022 at 8:43 AM Laurence Finston <[email protected] > wrote: For a particular application, I'm calling MP from within a program via a pipe and I want to read the output and use it for setting variables in my application. The intention is to use "point x of <path>" to take a path of length n and convert it into an equivalent path of length n*m where m is some whole number > 1 (within reason). The problem is the way the lines in the output of "show" are broken: The lines are fairly short (max. 80 characters, including the newline) and the x- and y-coordinates of the points can be broken across two lines, which makes parsing unnecessarily difficult. yes, it is a "feature". We have to deal with it. It would also be nice to limit the number of decimal places for the coordinates, by rounding or even by truncating. not with "double" but with "decimal" and "binary" we have numberprecision: if numbersystem="decimal": numberprecision:=6; fi if numbersystem="binary": numberprecision:=6; fi decimal and binary are slower than double, btw. As a workaround, I've written a macro to write the data I need to a file (see attachment), but it would be nicer if "show" could be used instead. I think this is the right way, not a workaround: write your data to a file , post-process the file with, for example, perl. -- luigi -- http://tug.org/metapost/ -- http://tug.org/metapost/