[metapost] Problem with readfrom

Karel horakk at math.cas.cz
Mon Jun 14 09:37:53 CEST 2010


Reinhard Kotucha napsal(a):
> But
> 
>   toto="datas/"&"fichier.dat"
>   numeric num;
> 
> without the semicolon produces a completely misleading error message:
> 
> ! Extra tokens will be flushed.
> <to be read again> 
>                    numeric
> l.4 numeric
>             num;
> ? 

I do not think so; the message clearly points to the exact place 
of code: end of line with toto before reading the next line...

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?
Of course, I should inspect graph.mp macros as the examples there 
work well.

Karel Horak


More information about the metapost mailing list