xHarbour Reference Documentation > Function Reference |
Retrieves a key/value pair from a hash by its ordinal position.
HGetPairAt( <hHash>, <nPos> ) --> { xKey, xValue }
The function returns a two-element array with the key and value found at position <nPos> in the hash <hHash>.
This function retrieves the key/value pair 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.
See also: | Hash(), HDelAt(), HGet(), HGetKeyAt(), HGetPos(), HGetValueAt() |
Category: | Hash functions , xHarbour extensions |
Source: | vm\hash.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The function retrieves key/value pairs 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 ) LOCAL aPair1 := HGetPairAt( hHash, 2 ) LOCAL aPair2 := HGetPairAt( hHash, 4 ) ? aPair1[1], aPair1[2] // result: B 20 ? aPair2[1], aPair2[2] // result: D 30 RETURN
http://www.xHarbour.com