renaming files from within maxima



On Sun, 8 Jul 2007, Robert Dodier wrote:

> On 7/8/07, sen1 at math.msu.edu <sen1 at math.msu.edu> wrote:
>
>>   I have a maxima program which writes output to a file.  If the file
>>   exists, it does not work.
>
> In what sense does it not work? Is there a Lisp or Maxima error,
> or does it run without complaint and yield an unexpected result?
In some sense it does work.  It simply reports the following.

Enter k_data_file name
"IPlist45-9.DAT";
Maxima encountered a Lisp error:


File-error in function LISP::FD-OPEN:  Error opening #P"file_out",
File exists.

Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.


The program was trying to write to the file "file_out" and, since it
already existed, it dumped out.  Actually, I don't want to append. I
want it to function, say, the way most screen snapshots
(e.g. ksnapshot) work.  If the file exists as
  "file_out" 
then the program creates a file called "fill_out001" and write to that
file.

If "file_out001" exists, then it writes to "file_out002", etc.

I am using the following for output:

s: openw("file_out");

If "file_out" exists, then it complains and produces an error message.

As I said, I would rather have this, than to corrupt or overwrite a
file which is already there.

-sen


>
> Maybe the global variable file_output_append is relevant here.
> file_output_append is honored by several Maxima file output
> functions; when it is true, output is appended, otherwise the
> output file is clobbered, if it exists.
>
> What is the function which is writing output? Maybe it should
> honor file_output_append, and it does not.
>
> Dunno whether the system function works on Windows.
>
> best
> Robert Dodier
>

-- 
  ---------------------------------------------------------------------------
  | Sheldon E. Newhouse            |    e-mail: sen1 at math.msu.edu           |
  | Mathematics Department         |       				   |
  | Michigan State University      | telephone: 517-355-9684                |
  | E. Lansing, MI 48824-1027 USA  |       FAX: 517-432-1562                |
  ---------------------------------------------------------------------------