writefile does not write



Am Samstag, den 05.11.2011, 19:44 +0000 schrieb Oliver Kullmann:
> > Maxima has an alternative function with the name appendfile. It works
> > like the function writefile, but does not use the underlying Lisp
> > function dribble.
> > 
> > Dieter Kaiser
> >
> 
> Apparently it uses dribble (and also nothing is written to file):
> (%i3) appendfile("Test.log");
> /* Starts dribbling to Test.log (2011/11/5, 20:40:47).*/                                                         
> some stuff ...
> 
> (%i6) closefile();
> /*Finished dribbling to Test.log.*/
> 
> Still Test.log is empty.
> 
> Oliver

The following is the implementation of the Maxima function appendfile.
There is no call to the Lisp function dribble. The message comes from
the function itself. appendfile opens a two-way-stream. The function
closefile checks if the dribble file was opened by Lisp dribble or the
Maxima function appendfile and closes the file accordingly.

But you are right I do not get an output on my system with Linux and
SBCL. The function appendfile seems not to work.

(defmfun $appendfile (name)
  (if (and (symbolp name)
	   (member (char (symbol-name name) 0) '(#\$) :test #'char=))
      (setq name (maxima-string name)))
  (if $appendfile (merror (intl:gettext "appendfile: already in
appendfile, you must call closefile first.")))
  (let ((stream  (open name :direction :output
		       :if-exists :append
		       :if-does-not-exist :create)))
    (setq *appendfile-data* (list stream *terminal-io* name))

    (setq $appendfile (make-two-way-stream
		       (make-echo-stream *terminal-io* stream)
		       (make-broadcast-stream *terminal-io* stream))
	  *terminal-io* $appendfile)
    (multiple-value-bind (sec min hour day month year)
	(get-decoded-time)
      (format t (intl:gettext "~&/* Starts dribbling to ~A (~d/~d/~d,
~d:~d:~d).*/~&")
	      name year month day hour min sec))
    '$done))

Dieter Kaiser