[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Polling stdin...
- From: Matthew Percival <matthew@...>
- Date: Tue, 07 Feb 2006 08:39:48 +1100
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?