$FUNCNAME$
  SETKEY()
$CATEGORY$
  TERMINAL/IO,KEYBOARD/MOUSE
$SUMMARY$
   Assign an action block to a key
$LANG_RU$
      .
$SYNTAX$
     SETKEY(<nInkeyCode>, [<bAction>]) --> bCurrentAction
$LANG_RU$
     SETKEY(<INKEY->, [< >]) -->   
$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.
$LANG_RU$
     <INKEY-> -  INKEY()- ,  
       .

     < > -   ,   
          .
$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.
$LANG_RU$
     SETKEY()   ,      
       NIL,         
     .
$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.
$LANG_RU$
     SETKEY()     ,  
         ,   
         .   -  
     ,        .
         ACHOICE(), DBEDIT(), MEMOEDIT(), 
      ACCEPT, INPUT, READ  WAIT.   INKEY()   
      .      32 .  
         F1   
          Help.

            ,
            
     PROCNAME(), PROCLINE()  READVAR(),     
       EVAL().     
          < >,   
       .

     SETKEY()   SET 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
$LANG_RU$
          ,     
       ,        EVAL()
             INKEY():

       #include "Inkey.ch"
       SETKEY(K_DN, { |cProc, nLine, cVar| MyProc(cProc, nLine, cVar) })
       ...
       ...<>
       ...
       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
$SEEALSO$
  EVAL(),INKEY()
$END$
