xHarbour Reference Documentation > Function Reference |
Retrieves the key from a hash by its ordinal position.
HGetKeyAt( <hHash>, <nPos> ) --> xKey
The function returns the key at position <nPos> in the hash <hHash>.
This function retrieves the key from the hash <hHash> at position <nPos>. If <nPos> is outside the valid range, a runtime error is raised. Use function HGetPos() to determine the ordinal position of a key.
The keys are inserted into the hash by their sorting order and cannot be moved or changed.
See also: | Hash(), HDelAt(), HGet(), HGetPairAt(), HGetKeys(), HGetPos(), HGetValueAt() |
Category: | Hash functions , xHarbour extensions |
Source: | vm\hash.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The function retrieves different keys by ordinal position. // 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 ) ? HGetKeyAt( hHash, 3 ) // result: C ? HGetKeyAt( hHash, 1 ) // result: A RETURN
http://www.xHarbour.com