xHarbour Reference Documentation > Function Reference |
Changes the value in an associative array by its ordinal position.
HaaSetValueAt( <hArray>, <nPos>, <xValue> ) --> NIL
The function returns always NIL.
This function changes the value of 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.
See also: | Array(), HaaGetKeyAt(), HaaGetPos(), HaaGetValueAt(), 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 changing // values in 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 HaaSetValueAt( hArray, 1, 100 ) hArray["Two"] := 200 hArray[3] := 300 ? hArray["One"] // result: 100 ? HaaGetValueAt( hArray, 2 ) // result: 200 ? hArray[3] // result: 300 RETURN
http://www.xHarbour.com