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

A

Aryk Grosz

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?
 
R

Rob Biedenharn

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 address removed)
 
A

Aryk Grosz

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?
 
V

Victor H. Goff III

[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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top