SET TYPEAHEAD

SET TYPEAHEAD

Set the size of the keyboard buffer

Syntax

      SET TYPEAHEAD TO <nKeyboardSize>

Arguments

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.

Description

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.

Seealso

ALTD(), CLEAR, TYPEAHEAD, INKEY(), KEYBOARD, NEXTKEY()

CLEAR TYPEAHEAD

CLEAR TYPEAHEAD

Empty the keyboard buffer

Syntax

      CLEAR TYPEAHEAD

Description

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.

Examples

      .  This example empties the keyboard buffer before invoking
      DBEDIT(), guaranteeing that any pending keys will not be executed:
      CLEAR TYPEAHEAD
      DBEDIT()

Seealso

KEYBOARD, SET TYPEAHEAD

ACCEPT

ACCEPT*

Place keyboard input into a memory variable

Syntax

      ACCEPT [<expPrompt>] TO <idVar>

Arguments

<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.

Description

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>.

Examples

      .  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

Seealso

@…GET, @…SAY, INKEY(), INPUT*, KEYBOARD, WAIT*

KEYBOARD

KEYBOARD

Stuffs the keyboard with a string.

Syntax

      KEYBOARD <cString>

Arguments

<cString> String to be processed, one character at a time, by the Harbour keyboard processor

Description

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.

Examples

      // Stuff an Enter key into the keyboard buffer
      KEYBOARD CHR(13)
      // Clear the keyboard buffer
      CLEAR TYPEAHEAD

Tests

      KEYBOARD CHR(13); ? INKEY() ==> 13
      KEYBOARD "HELLO"; CLEAR TYPEAHEAD; ? INKEY() ==> 0

Compliance

KEYBOARD is compliant with CA-Cl*pper 5.3

Seealso

CLEAR TYPEAHEAD, __KEYBOARD()

hb_keyPut()

HB_KEYPUT()

Put an inkey code to the keyboard buffer.

Syntax

      HB_KEYPUT( <nInkeyCode> )

Arguments

<nInkeyCode> is the inkey code, which should be inserted into the keyboard buffer.

Returns

There is no return value.

Description

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.

Examples

      // Stuff an Alt+PgDn key into the keyboard buffer
      hb_keyPut( K_ALT_PGDN )

Tests

      hb_keyPut( K_ALT_PGDN ) ; ? INKEY() ==> 417
      hb_keyPut( K_F11 ) ; ? INKEY() ==> -40

Compliance

Harbour

Files

Library is rtl

Seealso

KEYBOARD, CLEAR TYPEAHEAD, INKEY()

__Keyboard()

Template

Procedure

Name

__Keyboard()

Category

API

Subcategory

User interface

Oneliner

DO NOT CALL THIS FUNCTION DIRECTLY!

Syntax

      KEYBOARD <cString>
      CLEAR TYPEAHEAD

Arguments

<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).

Description

Clears the Harbour keyboard typeahead buffer and then inserts an optional string into it.

Examples

      // 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

Compliance

__Keyboard() is compliant with CA-Cl*pper 5.3

Files

Library is core

Seealso

CLEAR TYPEAHEAD, KEYBOARD