Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > "print" not showing immediately in output, but "puts" is

Reply
Thread Tools

"print" not showing immediately in output, but "puts" is

 
 
Aryk Grosz
Guest
Posts: n/a
 
      10-09-2008
Several times I have come across this issue. It seems to be dependent on
the environment, but I'll do a "print 'string'" and it wont show up
UNTIL I do a "puts". Then both strings will show up in the output window
in one shot.

Do you know how I can fix it to work properly?
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Rob Biedenharn
Guest
Posts: n/a
 
      10-09-2008
On Oct 9, 2008, at 3:28 PM, Aryk Grosz wrote:

> Several times I have come across this issue. It seems to be
> dependent on
> the environment, but I'll do a "print 'string'" and it wont show up
> UNTIL I do a "puts". Then both strings will show up in the output
> window
> in one shot.
>
> Do you know how I can fix it to work properly?



It's your terminal doing line buffering on the output.

Try:
$stdout.flush = true

Then see how it works for you.

-Rob

Rob Biedenharn http://agileconsultingllc.com
http://www.velocityreviews.com/forums/(E-Mail Removed)


 
Reply With Quote
 
 
 
 
Aryk Grosz
Guest
Posts: n/a
 
      10-10-2008
Thanks for the information Rob.

Should I run this line before each "print" command or do I just need to
run it once upon application startup?


Rob Biedenharn wrote:
> On Oct 9, 2008, at 3:28 PM, Aryk Grosz wrote:
>
>> Several times I have come across this issue. It seems to be
>> dependent on
>> the environment, but I'll do a "print 'string'" and it wont show up
>> UNTIL I do a "puts". Then both strings will show up in the output
>> window
>> in one shot.
>>
>> Do you know how I can fix it to work properly?

>
>
> It's your terminal doing line buffering on the output.
>
> Try:
> $stdout.flush = true
>
> Then see how it works for you.
>
> -Rob
>
> Rob Biedenharn http://agileconsultingllc.com
> (E-Mail Removed)


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Victor H. Goff III
Guest
Posts: n/a
 
      10-10-2008
[Note: parts of this message were removed to make it a legal post.]

STDOUT.flush needs to be put after output, but before a gets call, for
example... however, STDOUT.sync=true can be done just once, and it sets the
output to be flushed each time there is output.
Warmest Regards,

On Thu, Oct 9, 2008 at 7:33 PM, Aryk Grosz <(E-Mail Removed)>wrote:

> Thanks for the information Rob.
>
> Should I run this line before each "print" command or do I just need to
> run it once upon application startup?
>
>
>


 
Reply With Quote
 
Aryk Grosz
Guest
Posts: n/a
 
      10-10-2008
great, that seems to do it.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sh Crypto isakmp sa is showing Active but Tunnel is showing line protocol down. urvin Cisco 0 04-15-2008 08:17 AM
Folders not deleting immediately jawloc@hotmail.com ASP .Net 5 02-27-2007 01:59 PM
ASP 1.1: DataGrid - Showing/Not Showing Buttons Ray Booysen ASP .Net 2 03-28-2006 02:49 PM
Attribute with default value not immediately replaced... !? Nicolas XML 2 02-24-2006 02:39 PM
Tags not updated immediately Naveen Kohli ASP .Net Building Controls 0 11-22-2004 10:01 PM



Advertisments