- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have been using Lahey EM32 compiler, am considering moving to VF5.6 to make native Win app. Program is basically console mode, but during execution needs to check periodically if Escape key has been pressed, signalling user wants to interact. On browsing on line doc, it appears that I can use PEEKCHARQQ and related rtns, or use a thread if not in console mode, but I wonder if there isn't a canned routine that I can use to answer simple question "Escape pressed - yes or no". Examples I've seen in browsing the forum for "escape" entries seem cumbersome. I would think that Escape key querying is common enough to warrant a canned routine.
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is not a specific routine for checking for the Escape key - this is actually a rather uncommon request - I've never seen it before. PEEKCHARQQ can do what you want very simply - just look at the character and test it.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. One thing: does inquiring about a key having been pressed clear it from the buffer so the next read from the console doesn't get the character, or are just certain keys left for a legitimate read? As to need for looking at escape, I would think that any lengthy calculation might be a candidate for interrupting. If status messages are displayed as to progress of calculations, convergence, etc., a curious user might well want to say "hold on, there; I want to see what you have so far, perhaps change things." In chemical process simulation, the need is essential. Not all number crunching is for weather prediction.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, peeking doesn't remove the character from the keyboard buffer.
I can understand having a key to interrupt calculations, but what that key is might vary by application. Escape tends to be interpreted by Windows itself so is not a good choice here.
Steve
I can understand having a key to interrupt calculations, but what that key is might vary by application. Escape tends to be interpreted by Windows itself so is not a good choice here.
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to interrupt programs, too. I use the SIGNAL function for the signal SIGINT, which is raised by using Ctrl-C.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use PEEKCHARQQ but in conjunction with GETCHARQQ (which does remove the character from the buffer). Quote from docs:
If there is no keystroke waiting in the keyboard buffer, GETCHARQQ waits until there is one, and then returns it. Compare this to the function PEEKCHARQQ, which returns .TRUE. if there is a character waiting in the keyboard buffer and .FALSE. if not. You can use PEEKCHARQQ to determine if GETCHARQQ should be called. This can prevent a program from hanging while GETCHARQQ waits for a keystroke that isn't there.
Also, you can use a thread in a console mode, but I think that would be far more complicated than the problem justifies.
Jugolsav
If there is no keystroke waiting in the keyboard buffer, GETCHARQQ waits until there is one, and then returns it. Compare this to the function PEEKCHARQQ, which returns .TRUE. if there is a character waiting in the keyboard buffer and .FALSE. if not. You can use PEEKCHARQQ to determine if GETCHARQQ should be called. This can prevent a program from hanging while GETCHARQQ waits for a keystroke that isn't there.
Also, you can use a thread in a console mode, but I think that would be far more complicated than the problem justifies.
Jugolsav

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page