[Gambas-user] Waiting for keystrokes in a console

Benoît Minisini gambas at ...1...
Fri May 7 11:23:15 CEST 2010


> When I am in a console application, I merely have a
> 
> PUBLIC SUB Main()
> 
> END
> 
> which will once go through and stop. So I guess when the program has to
> wait for the user to press a key, I would have to monitor keystrokes
> like in good old BASIC times such as
> 
> while not instat(): wend
> a$ = keystr$
> 
> (Was it keystr, or what? Don't remember, it was something like that... :-)
> )
> 
> In Gambas, there is no instat() and stuff, so I thought maybe I can do
> that with something like
> 
> PUBLIC SUB MMain_KeyPress()
> 
> END
> 
> But when would this be activated? It wouldn't actually wait for a
> keystroke but Main would just run through and quit.
> 
> I know there is the Console example, but it requires a bash opened
> background and catching its events via Process and so on - isn't that a
> bit too much?
> 
> You see, I don't get on with this. Probably I'm watching the problem
> from the wrong direction ;-) so thanks for your help.
> 
> Regards
> 
> Rolf
> 

Catching the standard input is automatically done if you create a static 
public event handler "Application_Read" in your startup class.

But catching keystrokes easily is not possible, unless implementing a 
component based on ncurses.

Regards,

-- 
Benoît Minisini




More information about the User mailing list