| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Determines if a key is present in a hash.
HHasKey( <hHash>, <xKey> ) --> lExists
The function returns .T. (true) if the <xKey> exists in <hHash>, otherwise .F. (false) is returned.
This function tests if a key is present in a hash. HHasKey() is slightly more efficient than HGetPos(). It can be used for the same purpose but returns the numeric key position.
| See also: | Hash(), HGetKeys(), HGetPos(), HGetValues() |
| Category: | Hash functions , xHarbour extensions |
| Source: | vm\hash.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example demonstrates how a hash can be created for language
// dependent versions of a program.
PROCEDURE Main
LOCAL hHash := Hash()
LOCAL cLang := "German"
hHash[ cLang ] := NIL
hHash[ "Message" ] := ""
IF HHasKey( hHash, "English" )
hHash[ "Message" ] := "Hello World"
ELSEIF HHasKey( hHash, "German" )
hHash[ "Message" ] := "Hallo Welt"
ENDIF
? hHash[ "Message" ]
RETURN
http://www.xHarbour.com