xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HaaGetValueAt()

Retrieves the value from an associative array by its ordinal position.

Syntax

HaaGetValueAt( <hArray>, <nPos> ) --> xValue

Arguments

<hArray>
A variable referencing the associative array to retrieve a value from.
<nPos>
A numeric value specifying the ordinal position of the value to retrieve. It must be in the range between 1 and Len(<hArray>).

Return

The function returns the value at position <nPos> in the associative array <hArray>.

Description

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.

Info

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

Example

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

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