xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HEval()

Evaluates a code block with each hash element.

Syntax

HEval( <hHash>, <bBlock>, [<nStart>], [<nCount>] ) --> hHash

Arguments

<hHash>
A variable referencing the hash to process.
<bBlock>
This is the codeblock that is evaluated with each key/value pair of <hHash>
<nStart>
A numeric value indicating the first key/value pair of <hHash> to evaluate the code block with. It defaults to 1.
<nCount>
<nCount> is the nubmer of key/value pairs that are passed to <bBlock>. If omitted, <nCount> is calculated as 1+Len(<hHash>)-<nStart>.

Return

The function returns a reference to <hHash>.

Description

The function evaluates the code block <bBlock> with the key/value pairs of <hHash>. The code block receives three parameters: the key, the value and the numeric ordinal position of the current key/value pair in <hHash>. The return value of the code block is ignored.

Info

See also:AEval(), Hash(), HGetKeys(), HGetValues(), HScan()
Category: Code block functions , Hash functions , xHarbour extensions
Source:vm\hash.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The function illustrates the parameters passed to the
// HEval() code block.

   PROCEDURE Main
      LOCAL hHash := Hash( "A",10, "B",20 , "C",30 , "D",40 )

      HEval( hHash, {|k,v,i| QOut( k, v , i ) } )

      // Output:
      // A         10          1
      // B         20          2
      // C         30          3
      // D         40          4
   RETURN

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