[metapost] Problem with readfrom

Dan Luecking luecking at uark.edu
Mon Jun 14 18:15:54 CEST 2010


At 02:37 AM 6/14/2010, Karel wrote:

>On the other hand, I have almost no experience with using 
>scantokens, I also looked into mpman manual and finally was 
>surpriced with the result of the following example (with three lines 
>15\\13\\11 in fichier.dat):
>
>beginfig(1);
>string toto;
>toto="datas/fichier.dat";
>numeric n[];
>for k=1,2,3: n[k]=scantokens (readfrom toto); endfor
>show n1;
>show n2;
>show n3;
>endfig;
>
>metapost 2.07 gave me the following answer:
>
>(./fis.mp
> >> 0.06667datas
> >> 13
> >> 11 [1]
>
>Can anybody explain it or give me an advice how correctly get the 
>three numbers?

Somehow the "/" in the filename has been transformed into a
division producing datas/15 = 0.06667datas.

In Windows, I tried with datas\fichier.dat and obtained
   show n1;
   >> n1
I was certain the backslash was also being interpreted literally
(it means the same as relax), so I tested

toto="datas/fichier.dat";
string val;
   val = readfrom toto;
   show val;
and I got
   >> "datas/15"

So it would appear that readfrom produces the path portion
of the filename, concatenated with the the next line of the
file. I guess this has to qualify as a bug.

My version of mpost is:
   This is MetaPost, version 1.211


Dan


Daniel H. Luecking
Department of Mathematical Sciences
Fayetteville, Arkansas
http://www-cs-faculty.stanford.edu/~knuth/iaq.html 



More information about the metapost mailing list