Assign an action block to a key

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


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

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


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


     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.


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

        #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
           CASE nKey = K_PGDN
           CASE nKey = K_ESC

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

See Also: SET KEY

One response to “C5_SETKEY

  1. Pingback: C5_SET FUNCTION | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.