Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper 5.2 . The Guide To CA-Clippe - <b>inkey()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 INKEY()
 Extract a character from the keyboard buffer
------------------------------------------------------------------------------
 Syntax

     INKEY([<nSeconds>]) --> nInkeyCode

 Arguments

     <nSeconds> specifies the number of seconds INKEY() waits for a
     keypress.  You can specify the value in increments as small as one-tenth
     of a second.  Specifying zero halts the program until a key is pressed.
     If <nSeconds> is omitted, INKEY() does not wait for a keypress.

 Returns

     INKEY() returns an integer numeric value from -39 to 386, identifying
     the key extracted from the keyboard buffer.  If the keyboard buffer is
     empty, INKEY() returns zero.  INKEY() returns values for all ASCII
     characters, function, Alt-function, Ctrl-function, Alt-letter, and
     Ctrl-letter key combinations.

 Description

     INKEY() is a keyboard function that extracts the next key pending in the
     keyboard buffer and returns a value representing that key.  The value is
     also saved internally and can be accessed using LASTKEY().  If the
     <nSeconds> argument is specified and there are no pending keys in the
     buffer, program execution pauses until a key appears in the keyboard
     buffer, or <nSeconds> has elapsed.  The time INKEY() waits is based on
     the operating system clock and is not related to the microprocessor
     speed.  If <nSeconds> is zero, program execution pauses until a key is
     placed into the buffer.  Note that INKEY() is not a wait state and
     therefore SET KEYs are not active.

     INKEY() is similar to the NEXTKEY() function.  Unlike, INKEY(), however,
     NEXTKEY() reads but does not extract the key from the keyboard buffer.
     This is useful when you need to test for a key without processing it.

     INKEY() is the basic primitive of the CA-Clipper system for fetching
     keys from the keyboard buffer.  It is used for polling the keyboard or
     pausing program execution to wait for a keypress.  As an example, you
     can use INKEY() to terminate commands with a record scope such as LIST,
     LABEL FORM, and REPORT FORM by including it in a WHILE condition.  Refer
     to the example below.

     For a complete list of INKEY() codes and Inkey.ch constants, refer to
     the Error Messages and Appendices guide.

 Examples

     .  This example gets a key from the keyboard then displays its
        character value followed by the INKEY() value:

        #include "Inkey.ch"
        //
        LOCAL nInkeyCode := 0
        DO WHILE LASTKEY() != K_ESC
           ? "Press any key: "
           nInkeyCode := INKEY(0)
           ?? "Character:", CHR(nInkeyCode),;
              "INKEY() code:", LTRIM(STR(nInkeyCode))
        ENDDO
        RETURN

     .  This example uses INKEY() to poll for a user interrupt
        keypress during a REPORT FORM.  If the user presses Esc during the
        printing process, the REPORT FORM terminates:

        #include "Inkey.ch"
        //
        USE Sales INDEX Salesman NEW
        REPORT FORM Monthly FOR MONTH(SalesDate) = ;
              MONTH(DATE());
           WHILE INKEY() != K_ESC

 Files:  Library is CLIPPER.LIB, header file is Inkey.ch.

See Also: CHR() LASTKEY() NEXTKEY() SET KEY Inkey codes

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson