xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

SET FUNCTION

Associates a character string with a function key.

Syntax

SET FUNCTION <nFunctionKey> TO <cString>

Arguments

<nFunctionKey>
This is the numeric code for the function key to associate <cString> with. See table below.
TO <cString>
A character string to write into the keyboard buffer when the function key is pressed.

Description

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
NumberActual key
1 - 10F1 - F10
11 - 20Shift+F1 - Shift+F10
21 - 30Ctrl+F1 - Ctrl+F10
31 - 40Alt+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.

Info

See also:KEYBOARD, SET KEY, SetKey()
Category: Input commands , SET commands
Source:rtl\setfunc.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe