xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HaaDelAt()

Removes a key/value pair from an associative array.

Syntax

HaaDelAt( <hArray>, <nPos> ) --> NIL

Arguments

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

Return

The function returns always NIL.

Description

The function removes a key/value pair from the associative array <hArray> by its ordinal position. If <nPos> is outside the valid range, a runtime error is raised. Use function HaaGetPos() to determine the ordinal position of a key.

Info

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

Example

// The example creates an associative array and deletes
// the third key/value pair.

   PROCEDURE Main
      LOCAL hArray := Hash()

      HSetAACompatibility( hArray, .T. )

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

      ? hArray[ 3 ]               // result: 30
      ? hArray["Four"]            // result: 40

      HaaDelAt( hArray, 3 )

      ? hArray[ 3 ]               // result: 40
      ? hArray["Four"]            // result: 40
   RETURN

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