[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

"puts" without line feed

Bob Miner

8/10/2008 6:36:00 PM

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.
--
Posted via http://www.ruby-....

7 Answers

Patrick Li

8/10/2008 6:40:00 PM

0

it's "print"

print "line without line-feed"

or was it "prints" i don't remember.

-Patrick
--
Posted via http://www.ruby-....

Michael Guterl

8/10/2008 6:41:00 PM

0

On Sun, Aug 10, 2008 at 2:36 PM, Bob Miner <bobminer@lobo.net> 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

Thomas Wieczorek

8/10/2008 6:41:00 PM

0

Heya!

On Sun, Aug 10, 2008 at 8:36 PM, Bob Miner <bobminer@lobo.net> 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.

Sebastian Hungerecker

8/10/2008 7:10:00 PM

0

Bob Miner 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
--
Jabber: sepp2k@jabber.org
ICQ: 205544826

Bob Miner

8/10/2008 7:28:00 PM

0

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.
--
Posted via http://www.ruby-....

Tim Hunter

8/10/2008 7:53:00 PM

0

Bob Miner wrote:
> 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.

Try Sebastian's example. It does what you want.

--
RMagick: http://rmagick.ruby...

F. Senault

8/10/2008 9:05:00 PM

0

Le 10 août 2008 à 21:27, Bob Miner 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
--
Close your eyes Feel the ocean where passion lies
Silently the senses Abandon all defences
A place between sleep and awake End of innocence, unending masquerade
That's where I'll wait for you (Nightwish, Sleepwalker)