xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HGetKeys()

Collects all keys from a hash in an array.

Syntax

HGetKeys( <hHash> ) --> aKeys

Arguments

<hHash>
A variable referencing the hash to retrieve all keys from.

Return

The function returns a one-dimensional array holding in its elements copies of the keys of <hHash>.

Description

This function retrieves all keys from a hash and collects them in an array. The ordinal position of a key in the returned array is identical with the position in the hash.

Info

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

Example

// The function retrieves all keys of a hash.
// Note that the creation order of key/value pairs does not
// affect their insertion order (which is A B C D).

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

      ? aKeys[1]                   // result: A
      ? aKeys[3]                   // result: C
      ? HGetKeyAt( hHash, 1 )      // result: A
      ? HGetKeyAt( hHash, 3 )      // result: C
   RETURN

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