| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Associates a value with a key in a hash.
HSet( <hHash>, <xKey>, <xValue> ) --> NIL
The function returns always NIL.
HSet() is the functional equivalent of the hash access operator [ ] in conjunction with the inline assignment operator :=. It provides the same functionality for populating a hash or changing the value of existing key/value pais, but is slightly less efficient.
| See also: | Hash(), HGet(), HGetKeyAt(), HGetPairAt(), HSetValueAt(), HHasKey() |
| Category: | Hash functions , xHarbour extensions |
| Source: | vm\hash.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example demonstrates two posibilities of populating a hash
// and changing its values.
PROCEDURE Main
LOCAL hHash := {=>}
hHash[ "A" ] := 10
HSet( hHash, "B", 20 )
? ValToPrg( hHash )
// result: { "A" => 10, "B" => 20 }
hHash[ "B" ] := 100
HSet( hHash, "A", 200 )
? ValToPrg( hHash )
// result: { "A" => 200, "B" => 100 }
RETURN
http://www.xHarbour.com