[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-developer] capturing output strings
From: |
daly |
Subject: |
[Axiom-developer] capturing output strings |
Date: |
Sun, 22 May 2005 00:04:34 -0500 |
this seems to fail:
axiom
-> )lisp (setq result (make-array '(0) :element-type 'base-char :fill-pointer 0
:adjustable t))
Value = #<vector 0894bde4>
-> )lisp (with-output-to-string (|$algebraOutputStream| result)
(|parseAndInterpret| "(x+1)^9"))
>> System error:
#<vector 0894bde4> is not a string with a fill-pointer
This appears to be a bug as result certainly has a fill pointer.
This is an attempt to capture the output sent to the
stream |$algebraOutputStream| in some more elegant form
(instead of this kludge):
)lisp (progn
; we need a new output stream backed by a string
(setq tmpout (make-string-output-stream))
; we hold on to the regular algebra output stream
(setq save |$algebraOutputStream|)
; we capture the regular output into our string stream
(setq |$algebraOutputStream| tmpout)
; we generate output
(|parseAndInterpret| "(x+1)^9")
; we get the results from the algebra output stream
(setq result (get-output-stream-string |$algebraOutputStream|))
; we restore the regular algebra output stream
(setq |$algebraOutputStream| save)
; and return the result
result)
t