[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Do something until keypress

Peter Szinek

10/26/2006 12:20:00 PM

Hello,

I would like to emulate the good old Pascal 'loop until keypressed' code
snippet:

repeat
write("Hello");
until keypressed;

(also the borland c/c++ function kbhit() was similar).
Also I would like to continue the loop in the same manner unless the
user pressed a specific key.

Since ansi C/C++ does not support this functionality, I guess it is not
supported by Ruby either - and after searching around a bit I could not
find some good substitute yet.

I do no want a general solution - it is enough if it will run under
linux. It is also not a problem if it will require a gem or anything
else (like libcurses-ruby or something).

Any ideas?

TIA

--
Peter
http://www.rubyra...



1 Answer

Jano Svitok

10/26/2006 12:40:00 PM

0

On 10/26/06, Peter Szinek <peter@rubyrailways.com> wrote:
> Hello,
>
> I would like to emulate the good old Pascal 'loop until keypressed' code
> snippet:
>
> repeat
> write("Hello");
> until keypressed;
>
> (also the borland c/c++ function kbhit() was similar).
> Also I would like to continue the loop in the same manner unless the
> user pressed a specific key.
>
> Since ansi C/C++ does not support this functionality, I guess it is not
> supported by Ruby either - and after searching around a bit I could not
> find some good substitute yet.
>
> I do no want a general solution - it is enough if it will run under
> linux. It is also not a problem if it will require a gem or anything
> else (like libcurses-ruby or something).
>
> Any ideas?
>
> TIA
>
See previous thread: "Trouble using puts and getc in different threads"
and others.