Subject: Re: Standard output formatting control
From: (Rob Warnock)
Date: Fri, 09 Jun 2006 19:02:51 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
Pascal Bourguignon  <> wrote:
| "phertmuller" <> writes:
| > How can I do to get these numbers in the same position ? (So, after
| > printing 0, clean the output, and print the 1 in the same position).
| Now, if you just want a quick-and-dirty solution, you can use the
| Carriage Return ASCII code, in most terminal it will move the cursor
| at the beginning of the line without advancing to the next line:
| (loop for x from 0 below 3
|       do (format t "~C~4D" (code-char 13) x) 
|          (sleep 1)) 

In many Common Lisps, especially on Unix/Linux, formatted output
is not automatically flushed from buffers by a #\Return, only by
a #\LineFeed, so to get this to work as expected you will need to
add a (FORCE-OUTPUT) before the (SLEEP 1) [and similarly with the
CUP example later]:

     (loop for x from 0 below 3
	   do (format t "~C~4D" (code-char 13) x) 
	      (sleep 1)) 


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607