xHarbour Reference Documentation > Function Reference |
Changes the value in a hash by its ordinal position.
HSetValueAt( <hHash>, <nPos>, <xValue> ) --> NIL
The function returns always NIL.
This function changes the value of 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.
See also: | Hash(), HDelAt(), HGet(), HGetKeyAt(), HGetPairAt(), HGetPos(), HGetValueAt(), HSet() |
Category: | Hash functions , xHarbour extensions |
Source: | vm\hash.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The function changes values in a hash by ordinal position and by key. // 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 HSetValueAt( hHash, 3 , 123 ) hHash[ "A" ] := 789 ? HGetValueAt( hHash, 3 ) // result: 123 ? HGetValueAt( hHash, 1 ) // result: 789 RETURN
http://www.xHarbour.com