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.3 . Guide To CA-Clipper - <b>setkey()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 SETKEY()
 Assign an action block to a key
------------------------------------------------------------------------------
 Syntax

     SETKEY(<nInkeyCode>, [<bAction>]) --> bCurrentAction

 Arguments

     <nInkeyCode> is the INKEY() value of the key to be associated or
     queried.

     <bAction> specifies a code block that is automatically executed
     whenever the specified key is pressed during a wait state.

 Returns

     SETKEY() returns the action block currently associated with the
     specified key, or NIL if the specified key is not currently associated
     with a block.

 Description

     SETKEY() is a keyboard function that sets or queries the automatic
     action associated with a particular key during a wait state.  A wait
     state is any mode that extracts keys from the keyboard except for
     INKEY(), but including ACHOICE(), DBEDIT(), MEMOEDIT(), ACCEPT, INPUT,
     READ and WAIT.  Up to 32 keys may be assigned at any one time.  At
     startup, the system automatically assigns the F1 key to execute a
     procedure or user-defined function named Help.

     When an assigned key is pressed during a wait state, the EVAL() function
     evaluates the associated <bAction> and the parameters, PROCNAME(),
     PROCLINE(), and READVAR().  It is, however, not necessary to list
     arguments when specifying <bAction> if you do not plan to use them
     within the action block.

     SETKEY() is like the SET KEY command which associates a procedure
     invocation with a key.

 Examples

     .  This code fragment associates an action block with a key, and
        then, after getting a key using INKEY(), executes it with the EVAL()
        function:

        #include "Inkey.ch"
        SETKEY(K_DN, {|cProc, nLine, cVar| MyProc(cProc, ;
                          nLine, cVar)})
        .
        . <statements>
        .
        DO WHILE .T.
           nKey := INKEY(0)
           DO CASE
           CASE (bAction := SETKEY(nKey)) != NIL
              EVAL(bAction, PROCNAME(), PROCLINE(), READVAR())
           CASE nKey = K_PGUP
              Previous()
           CASE nKey = K_PGDN
              Next()
           CASE nKey = K_ESC
              EXIT
           ENDCASE
        ENDDO

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


See Also: SET KEY

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