Saluton!

* Juergen Lang; 2003-06-30, 12:44 UTC:
> Now my Q: Is it possible with ruby to diplay the percentage of the 
> current status always on the same position on the screen instead of 
> seperated by newlines or something like that?

A very portable way is this:

rubout = 8.chr * 4
0.upto(100) {|i|
  print rubout unless i == 0
  printf "%3d%%", i
  $stdout.flush
  sleep 1
}

rubout is backspace characters that remove the percentage text. At 
first run it is not written. Afterwards it removes the text already 
visible (you could output a dummy 0% so that the if statement is not 
needed). printf does output a three digit percentage (see man 3 
printf for details on printf). The most important statement is the 
flush statement.

On Unix the output only takes place if you output a "\n" character - 
unless you manually flush the buffer.

I use this kind of output for my mail downloader and it works 
flawlessly with one execption: If you press enter the output 
continues in the following line but that problem is present with many 
programs so I don't care.

Gis,

Josef 'Jupp' Schugt
-- 
Someone even submitted a fingerprint for Debian Linux running on the
Microsoft Xbox.  You have to love that irony :).
                               -- Fyodor on nmap-hackers / insecure.org