Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Lua Development Tools » io.read waits before any print() output?(Problems getting print to output before calls to io.read)
io.read waits before any print() output? [message #1008738] Wed, 13 February 2013 18:47 Go to next message
Eclipse Guest
Messages: 93
Registered: February 2013
Location: Vienna
Member
I am trying to run my script in the editor which has code something like this:

print('Enter your Name:')
io.read('*line')


When I run it does not print out 'Enter your Name' until after I type something in the console and hit enter. This kind of defeats the point of having a prompt. This applies to all print() functions that I have in code before or after the io.read(). Nothing gets printed until all of the io.read() commands have received input, then everything comes out afterward.

I have run the same code in a different editor (Zerobrane) and it works as I would expect (i.e. prints the prompt then waits for input).

Any suggestions?

Re: io.read waits before any print() output? [message #1009733 is a reply to message #1008738] Fri, 15 February 2013 15:57 Go to previous messageGo to next message
Marc Aubry is currently offline Marc Aubry
Messages: 83
Registered: August 2012
Member
Hi Kevin,

First, thanks to take time for feedback.

To work as you expect, the sdtout buffer have to be configured by adding the following line at the top of your file:
io.stdout:setvbuf('no')

As explain in the documentation here: http://wiki.eclipse.org/Koneki/LDT/Developer_Area/User_Guides/User_Guide_0.9#Local_Interpreters (buffer configuration part). You can also execute this line at each launch of your interpreter by adding the option -e "io.stdout:setvbuf('no')" to your interpreter in the configure interpreter preference page.

As other users may have the same expectation as you about the console behavior, I have also open this bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=400938 to set this interpreter argument option by default for JNLua interpreters.

Marc
Re: io.read waits before any print() output? [message #1009766 is a reply to message #1009733] Fri, 15 February 2013 17:02 Go to previous message
Eclipse Guest
Messages: 93
Registered: February 2013
Location: Vienna
Member
Thank you. Fixed the problem perfectly. I figured there was something I missed in the setup.

Kevin
Previous Topic:How to remote debug
Next Topic:LDT doesn't show up (ubuntu)
Goto Forum:
  


Current Time: Sat Oct 25 06:27:47 GMT 2014

Powered by FUDForum. Page generated in 0.08999 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software