FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Question about SET KEY
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Question about SET KEY
Posted: Fri Sep 12, 2008 08:55 PM

Hello,

I often use the statement SET KEY.

Is there a way to find out which functions are connected to certain keys.

For instance :

SET KEY VK_F10 TO TelMessage

Can I find out to which key the function TelMessage is connected ?

Thanks.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Question about SET KEY
Posted: Fri Sep 12, 2008 09:44 PM
Michel,

SetKey( nKey ) sets or retrieves the associated codeblock.

Here you have a working example:
#include "FiveWin.ch" 

function Main() 

   SET KEY VK_F10 TO TelMessage

   Eval( SetKey( VK_F10 ) )

return nil 

function TelMessage()

   MsgInfo( "From TelMessage" )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Question about SET KEY
Posted: Fri Sep 12, 2008 09:52 PM
If you want to do it the other way round, from the function name to get the associated key, then you have to keep an array yourself:

#include "FiveWin.ch" 

#command SET KEY <n> TO <f> => ( SetKey( <n>, {|p, l, v| <f>(p, l, v)} ), AAdd( aFunctions, { <n>, <(f)> } ) )

static aFunctions := {}

function Main() 

   SET KEY VK_F10 TO TelMessage

   MsgInfo( GetKey( "TelMessage" ) )

return nil 

function TelMessage()

   MsgInfo( "From TelMessage" )

return nil 

function GetKey( cProcName )

   local nAt := AScan( aFunctions, { | a | a[ 2 ] == cProcName } )
   
return If( nAt != 0, aFunctions[ nAt ][ 1 ], 0 )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Question about SET KEY
Posted: Fri Sep 12, 2008 10:51 PM

Antonio,

Thanks a lot. This is the answer I was looking for.

Have a nice weekend.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Continue the discussion