FUNCTIONS CT

KSetNum()

Query or change the state of Num Lock

Syntax

Signature
KSetNum( [lNewSwitch] ) --> lOldSwitch

Arguments

lNewSwitch

.T. turns Num Lock on, .F. turns it off. Without the argument the state does not change.

Return value

The state of Num Lock before the call: .T. on, .F. off.

Description

KSetNum() reads the state of Num Lock of the system. With lNewSwitch it also sets the state, for example on, so that the numeric keypad types digits.

Keep the returned value and pass it back later to restore the state of the user.

Notes

KSetNum() needs a GT. A GT that does not report the lock keys gives .F. Only the GT of Windows changes the state.

Example

KSetNum.prg
#if OS_LINUX
   REQUEST GTXWC
#else
   REQUEST GTWVT
#endif

PROCEDURE Main()

   LOCAL lOld := KSetNum()

   Check( 'KSetNum() is a logical value     ', ValType( lOld ), "L" )
   Check( 'KSetNum( lOld ) gives lOld       ', KSetNum( lOld ), lOld )
   Check( 'KSetNum() is bit 6 of KbdStat()  ', KSetNum(), IsBit( KbdStat(), 6 ) )

RETURN

STATIC PROCEDURE Check( cTitle, xResult, xExpected )

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

RETURN

Output

KSetNum() is a logical value     OK
KSetNum( lOld ) gives lOld       OK
KSetNum() is bit 6 of KbdStat()  OK

See also