Hi,
Is there a way to show output on a single line in the command prompt,
overwriting each time instead of linefeeding everytime I puts ‘my data’
?
I want the appearance of progress thru numerous iterations without
scrollin off into oblivion.
Hi,
Is there a way to show output on a single line in the command prompt,
overwriting each time instead of linefeeding everytime I puts ‘my data’
?
I want the appearance of progress thru numerous iterations without
scrollin off into oblivion.
it’s “print”
print “line without line-feed”
or was it “prints” i don’t remember.
-Patrick
On Sun, Aug 10, 2008 at 2:36 PM, Bob M. [email protected] wrote:
Hi,
Is there a way to show output on a single line in the command prompt,
overwriting each time instead of linefeeding everytime I puts ‘my data’
?I want the appearance of progress thru numerous iterations without
scrollin off into oblivion.
try print instead of puts
Heya!
On Sun, Aug 10, 2008 at 8:36 PM, Bob M. [email protected] wrote:
Hi,
Is there a way to show output on a single line in the command prompt,
overwriting each time instead of linefeeding everytime I puts ‘my data’
?
You can use print() instead of puts() which doesn’t add a linefeed.
Bob M. wrote:
Is there a way to show output on a single line in the command prompt,
overwriting each time instead of linefeeding everytime I puts ‘my data’
?
$stdout.sync = true
5.times do |i|
print “\r#{i}”
sleep 1
end
HTH,
Sebastian
Bob M. wrote:
then
does what I want at all, eh?
Thanks for kind & timely responses.
Try Sebastian’s example. It does what you want.
Le 10 août 2008 à 21:27, Bob M. a écrit :
so it rolls along “in place”
Try writing a “backspace” control caracter (ctrl-h, ascii code 8) ; for
example :
print “Countdown : 9”
9.downto(0) do |x|
print “\C-h#{x}”
sleep 1
end
puts
(I’m not entirely sure it’s completely cross-platform, but this simple
example works well with Windows and Unixoïds.)
Fred
On Mon Aug 11 04:27:56 2008, Bob M. wrote:
then
does what I want at all, eh?
Thanks for kind & timely responses.
You need to flush $stdout and move to the beginning of the line each
time:
jump = “\r\e[0K” # That is return to beginning of line and use the
# ANSI clear command “\e” or “\003”
(1…10).each do |i|
print jump + i
sleep 1
$stdout.flush
end
That should sort you.
uze guyz are SO close.
Print gives me
123456…to a new line…to another new line…
I’m tryin for
1
then
2 (where 1 was)
then
3 (where 1, then 2 were)
so it rolls along “in place”
Kinda silly, I know…I guess I should be happy the darn thing runs &
does what I want at all, eh?
Thanks for kind & timely responses.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs