| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Retrieves the value from a hash by its ordinal position.
HGetValueAt( <hHash>, <nPos> ) --> xValue
The function returns the value at position <nPos> in the hash <hHash>.
This function retrieves the value 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/value pair.
Values of key/value pairs can be changed by specifying the key for a hash and assigning a new value, or by using function HSetValueAt() which accepts the ordinal position of the value to change.
| See also: | Hash(), HDelAt(), HGet(), HGetKeyAt(), HGetPairAt(), HGetPos(), HSetValueAt() |
| Category: | Hash functions , xHarbour extensions |
| Source: | vm\hash.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The function retrieves different values 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 )
? HGetValueAt( hHash, 3 ) // result: 10
? HGetValueAt( hHash, 1 ) // result: 40
hHash[ "C" ] := 123
? HGetValueAt( hHash, 3 ) // result: 123
RETURN
http://www.xHarbour.com