| xHarbour Reference Documentation > Command Reference |
![]() |
![]() |
![]() |
Associates a character string with a function key.
SET FUNCTION <nFunctionKey> TO <cString>
SET FUNCTION is a compatibility command that associates a character string with a particular function key (F1..F10/F12). The function keys are numbered from 1 to 40 according to the following table:
Numeric codes for function keys
| Number | Actual key |
|---|---|
| 1 - 10 | F1 - F10 |
| 11 - 20 | Shift+F1 - Shift+F10 |
| 21 - 30 | Ctrl+F1 - Ctrl+F10 |
| 31 - 40 | Alt+F1 - Alt+F10 |
When a function key, or key combination, is associated with <cString>, this string is written into the keyboard buffer via SET KEY.
| See also: | KEYBOARD, SET KEY, SetKey() |
| Category: | Input commands , SET commands |
| Source: | rtl\setfunc.prg |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example demonstrates how the string associated with a function
// key can be read from the keyboard buffer.
#include "Inkey.ch"
PROCEDURE Main
LOCAL cStr
LOCAL nKey, bBlock
SET FUNCTION 2 TO "Edit"
DO WHILE Lastkey() <> K_ESC
nKey := Inkey(0)
IF ( bBlock := SetKey( nKey ) ) <> NIL
Eval( bBlock )
?
DO WHILE Nextkey() <> 0 // displays: Edit
?? Chr( Inkey() ) // when F1 is pressed.
ENDDO
ENDIF
ENDDO
RETURN
http://www.xHarbour.com