Question about SET KEY

Question about SET KEY

Postby driessen » Fri Sep 12, 2008 8: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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Antonio Linares » Fri Sep 12, 2008 9:44 pm

Michel,

SetKey( nKey ) sets or retrieves the associated codeblock.

Here you have a working example:
Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Fri Sep 12, 2008 9: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:

Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby driessen » 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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 76 guests