# SETKEY()

Assign an action block to a key

Syntax

  SETKEY( <anKey> [, <bAction> [, <bCondition> ] ] )

Arguments

  <anKey> is either a numeric key value, or an array of such values
  <bAction> is an optional code-block to be assigned
  <bCondition> is an optional condition code-block

Returns

  Current assigned action-block

Description

  The SetKey() function returns the current code-block assigned to a key when called with only the key value. If the action block (and optionally the condition block) are passed, the current block is returned, and the new code block and condition block are stored. A group of keys may be assigned the same code block/condition block by using an array of key values in place on the first parameter.

Examples

          local bOldF10 := setKey( K_F10, {|| Yahoo() } )
          ... // some other processing
          SetKey( K_F10, bOldF10 )
          ... // some other processing
          bBlock := SetKey( K_SPACE )
          if bBlock != NIL ...

          // make F10 exit current get, but only if in a get - ignores other
          // wait-states such as menus, achoices, etc...
          SetKey( K_F10, {|| GetActive():State := GE_WRITE },;
           {|| GetActive() != NIL } )
    Tests
          None definable

Status

  Ready

Compliance

  SETKEY() is mostly CA-Clipper compliant. The only difference is the addition of the condition code-block parameter, allowing set-keys to be conditionally turned off or on. This condition-block cannot be returned once set - see SetKeyGet()

Files

  Library is rtl

See Also

- HB_SETKEYSAVE()