small medium large xlarge

Generic-user-small
24 Jan 2014, 12:37
Chuen (2 posts)

I believe I have written a successful code:

puts "Lyrics of the song 99 Bottles of Beer"
counter = 99
  while counter != 0
    puts counter.to_s + ' bottles of beer on the wall, ' + counter.to_s + ' bottles of beer.'
	if	counter !=1
	puts 'Take one down and pass it around, ' + (counter-1).to_s + ' bottles of beer on the wall.'
	else
	puts 'Take one down and pass it around, no more bottles of beer on the wall.'
	end
	puts ''
	counter = counter - 1
  end
 puts 'No more bottles of beer on the wall, no more bottles of beer.'
 puts 'Go to the store and buy some more, 99 bottles of beer on the wall.'

When I run the program in command line, it cannot display all the lyrics. It seems that the output is too long and the first few lines have deleted.

Is it specifically an issue in Windows only? Any help that can let me displaying all the lyrics is welcome.

And I really feel quite frustrated because this is only the early stage of a very short program. How come people can code a large program with a very long output in Windows?

Med__2008.08.19.09.44.43_pragsmall
26 Jan 2014, 17:11
Chris Pine (63 posts)

This is probably because the Windows buffer is too short. Two ways that people get around this in general are to send long output to a file instead of to the screen, or to use a pager. (You can google these.)

Specific to Windows, though, you can increase the buffer size. When the command prompt is open, click the little icon on the menu bar. Choose “Properties” from the drop-down, and select the “Layout” tab. From here, you can set the height of the screen buffer size. (I have mine set to 5000, apparently. I must have done this years ago.) I also set the buffer size and the window size to be 120 wide.

Hope that helps.

Med__2008.08.19.09.44.43_pragsmall
26 Jan 2014, 17:13
Chris Pine (63 posts)

Actually, I think that changes only the current session. To change the defaults, click the little icon on the menu bar and choose “Defaults” from the drop-down. The rest is the same as if you chose “Properties”.

Generic-user-small
04 Feb 2014, 13:21
Chuen (2 posts)

It works, thanks

  You must be logged in to comment