lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


	I have been searching around on this topic, and have not come up with
anything substantial, so I suspect there is currently no option for
this, but I thought it best to ask, in case a skilled Lua programmer
knows a way.  Quite simply, I want to check stdin to see if there is
anything currently buffered, and only perform stdin:read() if there is.
As a simple example:

i = 1
while (i != 0) do
	if (stdin:read("*ready")) then -- somehow test if it's ready
		i = stdin:read("*all")
		print "Looping again...\n"

	So, if the user ever types a 0, the loop will exit; if the user types
nothing, it will continually print on the screen.  Perhaps a bad
example, but a nice, simple one.  Can this be done, or would something
like this have to be written in first?