NDX()

Keyboard

This command gives your program the ability to type. You can treat a string as if it had been typed at the keyboard.

Usage

KEYBOARD cString [ PLAIN ] [ CLEAR ]
KEYBOARD is handy for self-running demos and the like. But it's also useful when you want to force a particular menu choice or some other action.

The trickiest aspect of KEYBOARD is that the keyboarded characters aren't processed until the program reaches a wait state. They simply sit in the keyboard buffer, just as keystrokes typed by a user would. For example, if you KEYBOARD something in a control's method, the keystrokes aren't processed until the method finishes and control returns to the form. When the form is again waiting for input, the keyboarded keystrokes are removed from the buffer and processed in the order they were entered.

FoxPro uses a special notation to allow you to refer to key combinations as well as the special keys on the keyboard (Home, End, and so forth). You enclose the key name in curly braces, like {ALT+F3}. Check out the online help file under ON KEY LABEL for a list of special keys.

The PLAIN clause is handy when you've redefined a key but still need to keyboard it just as a character. PLAIN means that FoxPro should process the key simply as a character rather than checking for an ON KEY LABEL or macro for that keystroke. PLAIN is especially useful if you've redefined keys like Tab, Spacebar or Enter.

CLEAR is useful when your users have a habit of hitting keys when they shouldn't. It clears out the keyboard buffer before inserting the specified characters. This gives you better control over the exact sequence of events.

We KEYBOARD a lot less in Visual FoxPro than we did in FoxPro 2.x because the ability to call methods of other objects directly, together with access to so many system and user events, simply eliminates much of the need. Rather than building KEYBOARD into our applications, nowadays we tend to use it more in test scripts, which allows us to repeat a standard sequence of keystrokes to set up a system in a particular way for testing.

Example

* force a "copy" from the menu KEYBOARD "{CTRL+C}"

See Also

InKey(), LastKey(), On Key Label, Sys(1500)


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net