xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HaaSetValueAt()

Changes the value in an associative array by its ordinal position.

Syntax

HaaSetValueAt( <hArray>, <nPos>, <xValue> ) --> NIL

Arguments

<hArray>
A variable referencing the associative array to change a value in.
<nPos>
A numeric value specifying the ordinal position of the value to change. It must be in the range between 1 and Len(<hArray>).
<xValue>
<xValue> is the new value to assign at position <nPos> in <hArray>.

Return

The function returns always NIL.

Description

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.

Info

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

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe