xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HGetVaaPos()

Retrieves the sort order of all keys in an associative array.

Syntax

HGetVaaPos( <hArray> ) --> aSortOrder

Arguments

<hArray>
A variable referencing an associative array.

Return

The function returns a one dimensional array holding in its elements the numeric sort order of each key in <hArray>.

Description

Function HGetVaaPos() iterates an associative array and collects the sort order of each key in a regular array, which is returned. This is equivalent to calling HaaGetRealPos() for all elements of <hArray>.

Info

See also:Array(), HaaGetKeyAt(), HaaGetPos(), HaaGetRealPos(), HaaGetValueAt(), HaaSetValueAt(), Hash(), HSetAACompatibility()
Category: Associative arrays , Hash functions , xHarbour extensions
Source:vm\hash.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example displays the ordinal position and the
// sort order of keys in an associative array.

   PROCEDURE Main
      LOCAL hArray := Hash(), aSortOrder, i

      HSetAACompatibility( hArray, .T. )

      hArray[ "One"  ] := 10
      hArray[ "Two"  ] := 20
      hArray[ "Three"] := 30
      hArray[ "Four" ] := 40
      hArray[ "Five" ] := 50

      aSortOrder := HGetVAAPos( hArray )

      FOR i :=1 TO Len( aSortOrder )
         ? i, aSortOrder[i]
      NEXT

      ** Output:
      //     1       3
      //     2       5
      //     3       4
      //     4       2
      //     5       1
   RETURN

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