Question: passive console input

Hi, how is it that i’m able to read console input without halting the
program. I want my program to run and update itself, but when a user
presses a single key the program will read it precess it. Is there an
ansi function to do this? any non ansi function? i’m writing this
under windows.

Sorry guys, I meant to post this in the C group. but while its here,
i want to do this in ruby too. Is there a built in command for this in
ruby?

···

Hi, how is it that i’m able to read console input without halting the
program. I want my program to run and update itself, but when a user
presses a single key the program will read it precess it. Is there an
ansi function to do this? any non ansi function? i’m writing this
under windows.

Hi,

“AW” sturmpanzer@metacrawler.com wrote in message
news:58Oa9.140064$vg.23731191@twister.nyroc.rr.com

Hi, how is it that i’m able to read console input without halting the
program. I want my program to run and update itself, but when a user
presses a single key the program will read it precess it. Is there an
ansi function to do this? any non ansi function? i’m writing this
under windows.

What about this?

···

require ‘Win32API’

kbhit = Win32API.new(“crtdll”, “_kbhit”, [], ‘L’)
getch = Win32API.new(“crtdll”, “_getch”, [], ‘L’)

for i in 0 … 100000
puts “#{i} #{getch.Call.chr} pressed” if kbhit.Call != 0
end

Park Heesob

very nice!
Where can I get more documentation of the win32api for ruby?
I have ‘Programming Ruby’ but it barely touches on it.

···

What about this?


require ‘Win32API’

kbhit = Win32API.new(“crtdll”, “_kbhit”, [], ‘L’)
getch = Win32API.new(“crtdll”, “_getch”, [], ‘L’)

for i in 0 … 100000
puts “#{i} #{getch.Call.chr} pressed” if kbhit.Call != 0
end

Park Heesob