Set the size of the keyboard buffer
SET TYPEAHEAD TO <nKeyboardSize>
TO <nKeyboardSize> specifies the number of keystrokes the keyboard buffer can hold from a minimum of zero to a maximum of 4096. The default size of the keyboard buffer is machine-dependent but 16 is the minimum size.
SET TYPEAHEAD defines the size of the Clipper keyboard buffer that caches keystrokes input directly by the user. SET TYPEAHEAD, however, does not affect the number of characters that can be stuffed programmatically using the KEYBOARD command. When executed, SET TYPEAHEAD clears the keyboard buffer and sets the size to <nKeyboardSize>.
When TYPEAHEAD is SET TO zero, keyboard polling is suspended. An explicit request for keyboard input, however, will temporarily enable the keyboard and read any pending keystrokes from the BIOS buffer. Calling NEXTKEY() constitutes such an explicit request. NEXTKEY() reads any pending keystrokes from the BIOS buffer and returns the INKEY() value of the first keystroke read, or zero if no keystrokes are pending.
ALTD(), CLEAR, TYPEAHEAD, INKEY(), KEYBOARD, NEXTKEY()
Empty the keyboard buffer
CLEAR TYPEAHEAD is a keyboard command that clears all pending keys from the Clipper keyboard buffer. This is useful in user interface procedures or user-defined functions to guarantee that keys processed from the keyboard buffer are appropriate to the current activity and not pending from a previous activity. User functions called by ACHOICE() and DBEDIT() are especially sensitive to such keys.
Note that both the SET TYPEAHEAD and KEYBOARD commands also clear the keyboard buffer.
. This example empties the keyboard buffer before invoking DBEDIT(), guaranteeing that any pending keys will not be executed: CLEAR TYPEAHEAD DBEDIT()
KEYBOARD, SET TYPEAHEAD
Place keyboard input into a memory variable
ACCEPT [<expPrompt>] TO <idVar>
<expPrompt> is an optional prompt displayed before the input area. The prompt can be an expression of any data type.
<idVar> is the variable that will hold input from the keyboard. If the specified <idVar> does not exist or is not visible, a private variable is created.
ACCEPT is a console command and wait state that takes input from the keyboard and assigns it as a character string to the specified variable. When ACCEPT is executed, it first performs a carriage return/linefeed, displays the prompt, and then begins taking characters from the keyboard at the first character position following the prompt. You may input up to 255 characters. When input reaches the edge of the screen, as defined by MAXCOL(), the cursor moves to the next line.
ACCEPT supports only two editing keys: Backspace and Return. Esc is not supported. Backspace deletes the last character typed. Return confirms entry and is the only key that can terminate an ACCEPT. If Return is the only key pressed, ACCEPT assigns a null value (“”) to <idVar>.
. This example uses ACCEPT to get keyboard input from the user: LOCAL cVar ACCEPT "Enter a value: " TO cVar IF cVar == "" ? "User pressed Return" ELSE ? "User input:", cVar ENDIF
@…GET, @…SAY, INKEY(), INPUT*, KEYBOARD, WAIT*
Stuffs the keyboard with a string.
<cString> String to be processed, one character at a time, by the Harbour keyboard processor
This command stuffs the input buffer with <cString>.
The number of characters that can be stuffed into the keyboard buffer is controlled by the SET TYPEAHEAD command and may range from 0 to 32, 622, with each character being in the ASCII range of 0 to 255.
None of the extended keys may be stuffed into the keyboard buffer.
Issuing a KEYBOARD ” ” will clear the keyboard buffer.
// Stuff an Enter key into the keyboard buffer KEYBOARD CHR(13) // Clear the keyboard buffer CLEAR TYPEAHEAD
KEYBOARD CHR(13); ? INKEY() ==> 13 KEYBOARD "HELLO"; CLEAR TYPEAHEAD; ? INKEY() ==> 0
KEYBOARD is compliant with CA-Cl*pper 5.3
CLEAR TYPEAHEAD, __KEYBOARD()
Put an inkey code to the keyboard buffer.
HB_KEYPUT( <nInkeyCode> )
<nInkeyCode> is the inkey code, which should be inserted into the keyboard buffer.
There is no return value.
Inserts an inkey code to the string buffer. The buffer is *not* cleared in this operation. This function allows to insert such inkey codes which are not in the range of 0 to 255. To insert more than one code, call the function repeatedly. The zero code cannot be inserted.
// Stuff an Alt+PgDn key into the keyboard buffer hb_keyPut( K_ALT_PGDN )
hb_keyPut( K_ALT_PGDN ) ; ? INKEY() ==> 417 hb_keyPut( K_F11 ) ; ? INKEY() ==> -40
Library is rtl
KEYBOARD, CLEAR TYPEAHEAD, INKEY()
DO NOT CALL THIS FUNCTION DIRECTLY!
KEYBOARD <cString> CLEAR TYPEAHEAD
<cString> is the optional string to stuff into the Harbour keyboard buffer after clearing it first.
Note: The character “;” is converted to Chr( 13 ) (this is an undocumented CA-Cl*pper feature).
Clears the Harbour keyboard typeahead buffer and then inserts an optional string into it.
// Stuff an Enter key into the keyboard buffer KEYBOARD Chr( 13 ) // Clear the keyboard buffer CLEAR TYPEAHEAD // KEYBOARD Chr( 13 ); ? Inkey() // ==> 13 KEYBOARD ";" ? Inkey() // ==> 13 KEYBOARD "HELLO"; CLEAR TYPEAHEAD; ? Inkey() // ==> 0
__Keyboard() is compliant with CA-Cl*pper 5.3
Library is core
CLEAR TYPEAHEAD, KEYBOARD