FUNCTIONS CORE

SetKeyArray()

Give one action to several keys

Syntax

Signature
SetKeyArray( aInkey, bAction, [bCondition] ) --> NIL

Arguments

aInkey

The key codes.

bAction

The action of all the keys.

bCondition

A block that tells whether the action is active, see SetKey().

Return value

NIL.

Description

SetKeyArray() is the same as one SetKey( nKey, bAction, bCondition ) for each key of the array.

Example

SetKeyArray.prg
#include "inkey.ch"

PROCEDURE Main()

   LOCAL nCalls := 0

   SetKeyArray( { K_F7, K_F8 }, {|| nCalls++ } )

   Check( 'F7 has the action                ', ValType( SetKey( K_F7 ) ), "B" )
   Check( 'F8 has the action                ', ValType( SetKey( K_F8 ) ), "B" )

   SetKeyCheck( K_F8 )
   Check( 'the action runs for F8           ', nCalls, 1 )

RETURN

STATIC PROCEDURE Check( cTitle, xResult, xExpected )

   QOut( cTitle + IIF( xResult == xExpected, "OK", "ERROR" ) )

RETURN

Output

F7 has the action                OK
F8 has the action                OK
the action runs for F8           OK

See also