CT_KBDEMULATE

 KBDEMULATE()
 Inserts characters into the BIOS keyboard buffer to emulate keyboard input
------------------------------------------------------------------------------
 Syntax

     KBDEMULATE(<cListKeyValue>) --> nValue

 Argument

     <cListKeyValue>  Designates a keyboard input sequence to emulate.
     Use a maximum of 15 characters.

 Returns

     KBDEMULATE() returns the number of key codes it could not place in the
     BIOS buffer.

 Description

     KBDEMULATE() emulates keyboard input at a very low level.  This function
     uses the BIOS input buffer to emulate input.  This emulated input can
     then be used by another program.  For example, you might stuff the next
     DOS command prior to the end of the application.  Keyboard input for
     programs that use RUN() to be called is also feasible.  The buffer
     capacity is a maximum of 15 characters.  Some of the key codes may vary
     from keyboard to keyboard, but they still correspond to the values
     returned by SCANKEY().  Construct the codes as follows:

     CHR(ASCII code) + CHR(Scan code)

     As a rule, a scan code that is transmitted this way cannot be
     acknowledged by Clipper or any subsequent program.  For example, a
     DOS command can be passed as a string with spaces at each even position.
     This emulation of a scan code with a value of 32, would only cause
     problems when a subsequent program also checks the scan code (see
     Examples on the next page).

 Notes

     .  You can find the symbolic constants for key codes in the
        include file CTSCAN.CH.

     .  Problems may arise if you have incompatible hardware/BIOS, or
        programs that extend the keyboard buffer.

     .  Even though these emulated inputs occur at a low level, the
        code translations defined with SETKXLAT() still function.

 Examples

     .  These two programs always call each other reciprocally.
        Before returning to DOS, each program wedges the keys necessary to
        execute the other program in the BIOS buffer:

        Program 1 (PROG1.EXE)
        CLEAR
           @ 10, 10 SAY "Here is program 1  !"
           INKEY(5)                                // Wait a while...
           KBDEMULATE("P R O G 2 " + CHR(13))      // Start PROG2 in DOS
        RETURN

        Program 2 (PROG2.EXE)
        CLEAR
           @ 10, 10 SAY "Here is program 2  !"
           INKEY(5)                                // Wait a while...
           KBDEMULATE("P R O G 1 " + CHR(13))      // Start PROG1 in DOS
        RETURN

     .  This program returns to DOS and then re-calls itself.  In this
        case, the desired extra byte is created with the EXPAND() function.
        The last token in the full path is the EXE name which includes the
        file extension.  The first token is the file name:

        xeName  :=  TOKEN(EXENAME(), ":\")
        ExeName  :=  TOKEN(ExeName, ".", 1)
        KBDEMULATE(EXPAND(ExeName + CHR(13)))      // Expansion with blanks
        QUIT

     .  The correct way to implement EXPAND():

        * WRONG! No blank before CHR(13)
        KBDEMULATE(EXPAND("TEST") + CHR(13))
        * RIGHT! Blank before CHR(13)
        KBDEMULATE(EXPAND("TEST" + CHR(13)))

See Also: NUMLOW() NUMHIGH() SETKXLAT() KEYSEND()

 

Tools – Miscellaneous Functions

Introduction Miscellaneous Functions
ALLOFREE()*  Determines the maximum memory size allocation
BLANK()      Creates a blank value for each data type
COMPLEMENT() Forms the complement value of a data type
DATATYPE()*  Determines the data type of a variable or UDF
GETTIC()     Determines the number of timer ticks
KBDDISABLE() Locks/unlocks the keyboard
KBDEMULATE() Inserts characters into BIOS keyboard buffer to emulate input
KBDSPEED()   Sets keyboard auto repeat speed
KBDSTAT()    Tests for key shift state status, such as Ctrl and Shift
KBDTYPE()    Determines the type of keyboard in use
KEYSEC()     Triggers a key trap after a time delay
KEYTIME()    Triggers a key trap at a specific clock time
MILLISEC()   Time delay in milliseconds
NUL()        Converts the value returned by a function into a null string
SCANKEY()    Queries scan code of keyboard input
SETTIC()     Increases number of time ticks
SHOWKEY()    Continuously displays the INSERT and LOCK status
SOUND()      Creates tones (melodies) by designating frequency and duration
SPEED()      A comparison value used to determine the processor speed
STACKFREE()  Determines the remaining stack space
TOOLVER()    Queries the version number of the Clipper Tools in use
XTOC()       Converts an expression of any data type into a string