Karim BELABAS on Tue, 14 Oct 2003 16:20:56 +0200 (MEST)


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

Re: write in a file


On 14 Oct 2003, Markus Endres wrote:

> hallo together,
>
> 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?
>
> I need something like a logfile which only contains the result of my
> current computation. And when I start a new computation I don't need the
> old results in the file, so I want to overwrite it.
>
> Is there any possibility

I use these kind of things [ which you can modify to your liking ] :

  tmp_file(n) = Strexpand("$TMPDIR/gp.tmp$$" n)

  wtmp(x, n) =
  {
    local(file);
    file = tmp_file(n);
    system("rm -f "file);
    write(file, x)
  }

using the CVS branch. In older versions, Strexpand was Str(, 1).

Cheers,

    Karim.
-- 
Karim Belabas                     Tel: (+33) (0)1 69 15 57 48
Dép. de Mathématiques, Bât. 425   Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud              http://www.math.u-psud.fr/~belabas/
F-91405 Orsay (France)            http://www.parigp-home.de/  [PARI/GP]