On 5/17/08, andre maute <andre.maute at gmx.de> wrote:
> output_integer(z) := block(
>
> [tmp],
>
> tmp : file_output_append,
> file_output_append : true,
>
> stringout( "output.txt", "/* integer */" ),
> stringout( "output.txt", z ),
>
> file_output_append : tmp,
>
> return(z)
>
> );
> (%i3) output_integer(1)
> Error in `stringout' attempt
Thanks for pointing it out. I've committed a bug fix (shown below).
Be that as it may, I have some other comments.
(1) Instead of saving and restoring via a temporary variable, just
use block like this: block([variable_to_be_saved : foo], blah, blah, blah)
block restores the previous value.
(2) I find it's usually shorter and clearer to use with_stdout which just
collects all the output within in and directs it to a file; if you call
stringout you have to name the output file every time.
e.g. with_stdout("output.txt", print(this), print(that), grind(the_other))
(3) Might be simpler to open an output stream and write to it
via printf. Aside from printf, some other functions recognize streams,
including with_stdout and the numericalio functions.
hope this helps
Robert Dodier
PS.
Index: src/suprv1.lisp
===================================================================
RCS file: /cvsroot/maxima/maxima/src/suprv1.lisp,v
retrieving revision 1.68.4.1
diff -u -r1.68.4.1 suprv1.lisp
--- src/suprv1.lisp 26 Apr 2008 22:47:24 -0000 1.68.4.1
+++ src/suprv1.lisp 17 May 2008 15:42:59 -0000
@@ -884,7 +884,7 @@
(if $grind (mgrind (strmeval (car l)) savefile)
(princ (print-invert-case (maknam
(mstring (strmeval (car l)))))
savefile))
- (if (or (and (atom (car l)) (get (car l)
'nodisp)) (not $strdisp))
+ (if (or (and (symbolp (car l)) (get (car l)
'nodisp)) (not $strdisp))
(write-char #\$ savefile)
(write-char #\; savefile)))))
(setq maxima-error t)))