Markus Endres on 14 Oct 2003 17:35:37 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: write in a file


hi,

the unix shell command 'sed' works fine with the parigp command
'extern'.

so you can do something like this in gp

getline(n) =
{
return(extern("sed -n "n"p file"));
}


where n is the number of the line you want to read from the file 'file'.

now you have only to write a for-loop which runs from the first line you
want to the last one. ok, you must know the number of lines in the file,
but if you wrote the file with 'write()', thats easy.

maybe you should forget the 'x=' in the front of your expression.


cheers

me







-----Forwarded Message-----

> From: Dirk Laurie <dirk@siegfried.wisk.sun.ac.za>
> To: pari-users <pari-users@list.cr.yp.to>
> Subject: Re: write in a file
> Date: 14 Oct 2003 16:52:53 +0200
> 
> Markus Endres skryf:
> > 
> > I know the command 'write' to write the output of a computation (or
> > something else) to a file. 
> > 
> > but this appends the output to the file. Is there any possibility to
> > overwrite this file? 
> > 
> While the topic of files is hot, and since I got no reply
> the previous time round:
> 
> Can one read in from a Pari-GP-written file one item at a time?
> For example, in a loop I use 'write(filename,x)'.  It creates
> a lot of lines starting with 'x='.  
> 
> If I say 'read(filename)', the whole file is read, and all the
> values of x except the last are lost.  I want to read one, do
> something to it, read another, etc.
> 
> Dirk
-- 

===============================================================
markus endres 			phone : +49-(0)8291-9569
schwelcherstr. 4		fax   : +49-(0)8291-9568
86441 steinekirch		mobile: 0160-7539890

e-mail: me@mendres.org		web   : http://www.mendres.org
icq   : 43149758		GPG   : public key 0xEB9AC078
===============================================================