[metapost] Problem with readfrom

Christophe Poulain christophe.poulain at melusine.eu.org
Mon Jun 14 13:01:30 CEST 2010


Le Mon, 14 Jun 2010 08:37:53 +0100,
Karel <horakk at math.cas.cz> a écrit :

> 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.

Yes, i've forgotten the semi-colon but the problem exists always. It's
the 0.06667datas.
Metapost seems to do 1/15 then read correctly the other lines.

> 
> Karel Horak
> --
> http://tug.org/metapost/

Christophe Poulain



More information about the metapost mailing list