CapsLock(), InsMode(), NumLock()

These functions are really cool because they let you change the state of the user's keyboard programmatically. That's right—these functions let you turn the Caps Lock and Num Lock keys on and off and change from insert to overwrite mode and back. They also tell you the state of those items before you changed it.

Usage

lReturnValue = CAPSLOCK( [ lNewState ] )
lReturnValue = INSMODE( [ lNewState ] )
lReturnValue = NUMLOCK( [ lNewState ] )

Parameter

Value

Meaning

lNewState

 

.T.

Turn the setting on.

.F.

Turn the setting off.

Omitted

Don't change the setting.

lReturnValue

.T.

The setting was on before calling the function.

.F.

The setting was off before calling the function.


Perhaps most cool of all is that you can actually see the light on the keyboard go on or off for CAPSLOCK() and NUMLOCK().


Example

* Switch to uppercase
lOldCaps = CAPSLOCK(.T.)
* now have user perform uppercase entry
* now reset it
CAPSLOCK(lOldCaps)
 
* reverse the insert setting
INSMODE(.NOT. INSMODE())
The only problem with the example is there's nothing to stop the user from pressing the Caps Lock key himself and turning caps off.Now, there are right ways and wrong ways to toggle these settings. The wrong way, used by Ted's remote control package, is to switch off the Num Lock, not inform the operator, and leave it off when the package completes. Wrong, wrong, wrong. The entire idea behind the PC Revolution (just in case you're too young to remember) was empowerment of the end users. We cannot take back control of the horizontal and vertical, folks, they're gone and they ain't comin' back no more. The right way to change these settings is to let the user know, either through a status bar message or icon, or a message box, that you've switched off their Caps Lock because you knew it was what they wanted you to do, with the option to turn it right back on again. Give the user options to save preferences to a file, so the poor user who doesn't have a separate cursor control panel can have his Num Lock off, while you don't pester everyone else.

See Also

Format, Lower(), Upper()


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .