xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HGet()

Retrieves the value associated with a specified key.

Syntax

HGet( <hHash>, <xKey> ) --> xValue

Arguments

<hHash>
A variable referencing the hash to retrieve a value from.
<xKey>
<xKey> is the key to retrieve the associated value of.

Return

The function returns the value associated with the key <xKey>.

Description

The function retrieves the value <xValue> from the hash <hHash> associated with the key <xKey>.

If the key is not found in the hash, a runtime error is raised. Use function HHasKey() to determine the existence of a key.

Info

See also:Hash(), HGetKeyAt(), HGetPairAt(), HGetValueAt(), HHasKey(), HSet()
Category: Hash functions , xHarbour extensions
Source:vm\hash.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The function retrieves values by key.

   PROCEDURE Main
      LOCAL hHash := Hash( "A",10, "B",20 , "C",30 , "D",40 )

      ? HGet( hHash, "B" )             // result: 20

      ? HGet( hHash, "D" )             // result: 40

      ? HGet( hHash, "Z" )             // runtime error
   RETURN

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