xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HHasKey()

Determines if a key is present in a hash.

Syntax

HHasKey( <hHash>, <xKey> ) --> lExists

Arguments

<hHash>
<hHash> is identifier of the hash to test for the presence of a key.
<xKey>
This is the key to search for in <hHash>.

Return

The function returns .T. (true) if the <xKey> exists in <hHash>, otherwise .F. (false) is returned.

Description

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.

Info

See also:Hash(), HGetKeys(), HGetPos(), HGetValues()
Category: Hash functions , xHarbour extensions
Source:vm\hash.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

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

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