From burkhard at cs.ucsd.edu Mon Jan 2 16:56:42 2017 From: burkhard at cs.ucsd.edu (Walt Burkhard) Date: Mon, 2 Jan 2017 07:56:42 -0800 Subject: [metapost] question Message-ID: Hello, I am wondering about MetaPost's input facility. A command something like "fscanf" might be very useful. I am considering creating a MetaPost program P that would require input as it is not for a specific drawing. My approach to this currently is to run a second program (written in C) to create proper MetaPost input for the program P. Many thanks in advance for your thoughts. Walt Burkhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From burkhard at cs.ucsd.edu Thu Jan 5 22:37:15 2017 From: burkhard at cs.ucsd.edu (Walt Burkhard) Date: Thu, 5 Jan 2017 13:37:15 -0800 Subject: [metapost] a better question Message-ID: Hello I have a short metapost program attached the uses the reads from and scan token commands. I do not understand why the program works in the way it does. There are two files: the file named stringTest contains one line 2.56 7.23 The file named test.mp is shown below. numeric n ; string jkjk ; jkjk := readsfrom ( "stringTest" ) ; message ( jkjk ) ; % shows 2.56 7.23 n := scantoken ( jkjk ) ; % this parses/reads 2.56 and sets n to be 2.56 % evidently. message ( "n = "&decimal n ) ; % shows n = 2.56 n := scantoken ( jkjk ) ; % still sets n to be 2.56 I have attached both files here. Any suggestions on how I should be reading the second numeric value from the string would be appreciated. The User's guide says that the scantoken command processes tokens sequentially. (page 17) Many thanks in advance. Walt Burkhard -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: test.mp Type: application/octet-stream Size: 336 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: stringTest Type: application/octet-stream Size: 11 bytes Desc: not available URL: From dabell69 at earthlink.net Thu Jan 5 22:54:28 2017 From: dabell69 at earthlink.net (Dan T. Abell) Date: Thu, 5 Jan 2017 14:54:28 -0700 Subject: [metapost] a better question In-Reply-To: References: Message-ID: <8BAB3ECE-EEAF-4274-B898-E8E09BEB07A7@earthlink.net> You might consider having a look at some work done by Anthony Phan: http://www-math.univ-poitiers.fr/~phan/statsmac.html He implemented a readdata function, which might do what you want. At a minimum, you could examine his implementation. Cheers, Dan > On 5 Jan 2017, at 14:37, Walt Burkhard wrote: > > Hello > > I have a short metapost program attached the uses the reads from and > scan token commands. I do not understand why the program works > in the way it does. There are two files: the file named stringTest > contains one line 2.56 7.23 The file named test.mp is shown below. > > numeric n ; string jkjk ; > > jkjk := readsfrom ( "stringTest" ) ; message ( jkjk ) ; % shows 2.56 7.23 > > n := scantoken ( jkjk ) ; % this parses/reads 2.56 and sets n to be 2.56 > % evidently. > message ( "n = "&decimal n ) ; % shows n = 2.56 > > n := scantoken ( jkjk ) ; % still sets n to be 2.56 > > I have attached both files here. Any suggestions on how I should be reading the > second numeric value from the string would be appreciated. The User's guide > says that the scantoken command processes tokens sequentially. (page 17) > > Many thanks in advance. > > Walt Burkhard > -- > http://tug.org/metapost/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From luigi.scarso at gmail.com Fri Jan 6 12:34:10 2017 From: luigi.scarso at gmail.com (luigi scarso) Date: Fri, 6 Jan 2017 12:34:10 +0100 Subject: [metapost] a better question In-Reply-To: <8BAB3ECE-EEAF-4274-B898-E8E09BEB07A7@earthlink.net> References: <8BAB3ECE-EEAF-4274-B898-E8E09BEB07A7@earthlink.net> Message-ID: On Thu, Jan 5, 2017 at 10:54 PM, Dan T. Abell wrote: > You might consider having a look at some work done by Anthony Phan: > http://www-math.univ-poitiers.fr/~phan/statsmac.html > He implemented a readdata function, which might do what you want. > At a minimum, you could examine his implementation. Nice link, thank you for sharing. -- luigi From luigi.scarso at gmail.com Fri Jan 6 12:18:36 2017 From: luigi.scarso at gmail.com (luigi scarso) Date: Fri, 6 Jan 2017 12:18:36 +0100 Subject: [metapost] a better question In-Reply-To: References: Message-ID: On Thu, Jan 5, 2017 at 10:37 PM, Walt Burkhard wrote: > Hello > > I have a short metapost program attached the uses the reads from and > scan token commands. I do not understand why the program works > in the way it does. There are two files: the file named stringTest > contains one line 2.56 7.23 The file named test.mp is shown below. > > numeric n ; string jkjk ; > > jkjk := readsfrom ( "stringTest" ) ; message ( jkjk ) ; % shows 2.56 > 7.23 > > n := scantoken ( jkjk ) ; % this parses/reads 2.56 and sets n to be > 2.56 > % evidently. > message ( "n = "&decimal n ) ; % shows n = 2.56 > > n := scantoken ( jkjk ) ; % still sets n to be 2.56 > > I have attached both files here. Any suggestions on how I should be reading > the > second numeric value from the string would be appreciated. The User's > guide > says that the scantoken command processes tokens sequentially. (page 17) > > Many thanks in advance. > > Walt Burkhard > > -- > http://tug.org/metapost/ It seems ok to me, your program is not correct. # mpost test.mp This is MetaPost, version 1.9991 (TeX Live 2017/dev) (kpathsea version 6.2.3/dev) (/texlive/2016/texmf-dist/metapost/base/mpost.mp (/texlive/2016/texmf-dist/metapost/base/plain.mp Preloading the plain mem file, version 1.005) ) (./test.mp 2.56 7.23 ! Extra tokens will be flushed. 7.23 2.56 7.23 ; l.7 n := scantokens ( jkjk ) ; ? -- luigi From burkhard at cs.ucsd.edu Mon Jan 9 18:32:35 2017 From: burkhard at cs.ucsd.edu (Walt Burkhard) Date: Mon, 9 Jan 2017 09:32:35 -0800 Subject: [metapost] another quick question Message-ID: Hello, I have just downloaded the metapost-1.999-src.tar.bz2.mdlp file. How do I remove the mdlp suffix so I can view the source? many thanks in advance. Walt Burkhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From nvitacolonna at gmail.com Mon Jan 16 16:39:08 2017 From: nvitacolonna at gmail.com (Nicola) Date: Mon, 16 Jan 2017 16:39:08 +0100 Subject: [metapost] MPlib: detect bye/end In-Reply-To: References: Message-ID: On 15/12/2016 15:23, Nicola wrote: > On 15/12/2016 12:48, luigi scarso wrote: >> MetaPost rev. 2107 has a new function mp_finished that returns >> mp->finished as boolean, Luigi, is rev. 2107 publicly available? Nicola From luigi.scarso at gmail.com Mon Jan 16 16:45:08 2017 From: luigi.scarso at gmail.com (luigi scarso) Date: Mon, 16 Jan 2017 16:45:08 +0100 Subject: [metapost] MPlib: detect bye/end In-Reply-To: References: Message-ID: Il 16 gen 2017 16:40, "Nicola" ha scritto: On 15/12/2016 15:23, Nicola wrote: > On 15/12/2016 12:48, luigi scarso wrote: > MetaPost rev. 2107 has a new function mp_finished that returns >> mp->finished as boolean, >> > Luigi, is rev. 2107 publicly available? Nicola -- http://tug.org/metapost/ Latest revision is 2114 from trunk, but you have to compile from source. -- luigi -------------- next part -------------- An HTML attachment was scrubbed... URL: