Hi,
I am using SLIME + XEmacs + CLisp.
I wanted to try CL-FAD package (for file and directory manipulation) so
I wrote this simple test (using mpgtx utility to look at mp3 file
info):
(load "C:/Linux/cl-fad-0.3.2/load.lisp")
(in-package #:cl-fad-test)
(let ((files (list-directory "C:/Music")))
(dolist (item files)
(setq cmd-str (concatenate 'string "mpgtx -i " (namestring item)))
(with-open-stream (*output* (ext:run-shell-command cmd-str :output
:stream))
(loop for line = (read-line *output* nil)
when line do
(progn
(format t "~a~%" line))))))
It will display the outpout of first mpgtx -i some.mp3 and hang.
I have to go to the Task manager and kill lisp.exe process.
Any suggestions what's wrong here?
Andrei
On 27 Sep 2005 14:23:51 -0700, ·········@yahoo.com wrote:
> (let ((files (list-directory "C:/Music")))
> (dolist (item files)
> (setq cmd-str (concatenate 'string "mpgtx -i " (namestring item)))
> (with-open-stream (*output* (ext:run-shell-command cmd-str :output
> :stream))
> (loop for line = (read-line *output* nil)
> when line do
> (progn
> (format t "~a~%" line))))))
>
> It will display the outpout of first mpgtx -i some.mp3 and hang. I
> have to go to the Task manager and kill lisp.exe process. Any
> suggestions what's wrong here?
I don't know mpgtx but here are some suggestions:
- Why do you need the variables FILES?
(dolist (item (cl-fad:list-directory "C:/Music"))
...)
will do the same thing.
- You're changing the value of a variable (CMD-STR) that you haven't
declared before. This is calling for undefined behaviour, you
shouldn't do it.
Again, you don't need the variable:
(ext:run-shell-command (format nil "mpgtx -i ~A" (namestring item)) ...)
- The PROGN within the LOOP isn't needed.
- You can use WRITE-LINE instead of FORMAT in the last line of your
code.
- Your inner loop doesn't seem to end - try WHILE instead of WHEN.
Cheers,
Edi.
--
Lisp is not dead, it just smells funny.
Real email: (replace (subseq ·········@agharta.de" 5) "edi")
·········@yahoo.com writes:
> Hi,
>
> I am using SLIME + XEmacs + CLisp.
> I wanted to try CL-FAD package (for file and directory manipulation) so
> I wrote this simple test (using mpgtx utility to look at mp3 file
> info):
>
> (load "C:/Linux/cl-fad-0.3.2/load.lisp")
> (in-package #:cl-fad-test)
>
> (let ((files (list-directory "C:/Music")))
> (dolist (item files)
> (setq cmd-str (concatenate 'string "mpgtx -i " (namestring item)))
> (with-open-stream (*output* (ext:run-shell-command cmd-str :output
> :stream))
> (loop for line = (read-line *output* nil)
> when line do
> (progn
> (format t "~a~%" line))))))
>
> It will display the outpout of first mpgtx -i some.mp3 and hang.
> I have to go to the Task manager and kill lisp.exe process.
> Any suggestions what's wrong here?
Read again your loop.
It doesn't hang, it loops forever.
--
__Pascal Bourguignon__ http://www.informatimago.com/
The rule for today:
Touch my tail, I shred your hand.
New rule tomorrow.