[Maxima] reading a string from keyboard

van Nek van.nek at arcor.de
Sat Sep 6 04:29:50 CDT 2008


when I load an old version of stringproc.lisp I can reproduce, that readline(true) and 
readline(false) worked somehow. 
Entering readline(true); makes Maxima appear to hang, but you had been able to type in 
characters behind it:

(%i1) load("H:/Programme/Maxima-
(%i2) stringdisp:true$
(%i3) readline(true);  qwe qwe;
(%o3)                            "  qwe qwe;"

Readline was designed to read from streams from files opened by the openr function. The 
actual version of stringproc.lisp errors if the stream is not regarded as a stream on Lisp 
level. So it errors if you use true or false. 

For reading from the standard input you can use the function read:

(%i4) read("my text");
my text 
"qwe QWE Qwe";
(%o4)                            "qwe QWE Qwe"
(%i5) stringp(%);
(%o5)                                true

Two remarks:
1. read without argument shows the same behaviour as the above described for the old 
readline. It seems to hang. I regard this as a bug.
(%i6) read(); "qwe QWE Qwe";
(%o6)                            "qwe QWE Qwe"

2. read can read more than only strings:
(%i7) read("");
(%o7)                                 qwe
(%i8) symbolp(%);
(%o8)                                true
(%i9) read("");
(%o9)                                 123
(%i10) numberp(%);
(%o10)                               true

Volker van Nek

Am 5 Sep 2008 um 22:50 hat Jussi Eloranta geschrieben:

> Hi,
> I just recently noticed that readline(true) (or readline(false)) no 
> longer reads a string from the keyboard (stdin). It used to work before 
> 5.15 - probably this was not the correct way of doing it but couldn't 
> figure out anything else at that time. Note that I want to read a string 
> - not expression. This string can be, for example, a path name which is 
> not a valid expression obviously.
> After testing a bit, I found out that the following seems to work now:
> readline(?\*standard\-input\*)
> where the stream refers to the corresponding lisp stream name that 
> points to standard input. This also works well with wxmaxima (which 
> communicates via pipes I suppose). Is this the right way of doing this? 
> Meaning that is it standard enough that it should work with future 
> maxima releases as well.
> It might be a good idea to include the pre-existing stream names that 
> are accessible in maxima in the manual - the previous one was
> not trivial to figure out.
> Jussi Eloranta
> Cal State Northridge
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima

More information about the Maxima mailing list