xHarbour Reference Documentation > Function Reference |
Retrieves the value from an associative array by its ordinal position.
HaaGetValueAt( <hArray>, <nPos> ) --> xValue
The function returns the value at position <nPos> in the associative array <hArray>.
This function retrieves the value from the associative array <hArray> at position <nPos>. If <nPos> is outside the valid range, a runtime error is raised. Use function HaaGetPos() to determine the ordinal position of a key/value pair.
Values of key/value pairs can be changed by specifying the key for an 4associative array and assigning a new value, or by using function HaaSetValueAt() which accepts the ordinal position of the value to change.
See also: | Array(), HaaGetKeyAt(), HaaGetPos(), HaaSetValueAt(), Hash(), HSetAACompatibility() |
Category: | Associative arrays , Hash functions , xHarbour extensions |
Source: | vm\hash.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example outlines the possibilities of retrieving // values from an associative array. PROCEDURE Main LOCAL hArray := Hash() HSetAACompatibility( hArray, .T. ) hArray[ "One" ] := 10 hArray[ "Two" ] := 20 hArray[ "Three"] := 30 hArray[ "Four" ] := 40 hArray[ "Five" ] := 50 ? HaaGetValueAt( hArray, 1 ) // result: 10 ? HaaGetValueAt( hArray, 5 ) // result: 50 ? hArray[1] // result: 10 ? hArray[5] // result: 50 ? hArray["One"] // result: 10 ? hArray["Five"] // result: 50 RETURN
http://www.xHarbour.com