xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Eval()

Evaluates a code block.

Syntax

Eval( <bBlock> [, <xValue,...> ] )   --> xReturn

Arguments

<bBlock>
A code block to be evaluated
<xValue>
Any number of values to be passed as arguments to the code block.

Return

The function returns the value of the last expression inside the code block.

Description

This function evaluates the code block <bBlock> and passes on to it all parameters specified as the comma separated list <xValues,...>. A code block can contain multiple, comma separated expressions that are executed from left to right. The value of the last expression executed in the code block is used as return value of Eval().

Code blocks are values that contain executable code. Normally, the xHarbour compiler creates the code associated with code blocks at compile time. It is possible, however, to create code blocks at runtime of an application. This is accomplished by the macro operator (&) which compiles a character string holding the syntax for a code block at runtime.

Info

See also:AEval(), AScan(), ASort(), DbEval(), FieldBlock()
Category: Code block functions , Indirect execution
Source:vm\evalhb.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example outlines basic rules for code block usage.

   PROCEDURE Main
      LOCAL bBlock

      bBlock := {|x| QOut(x) }

      Eval( bBlock, Date() )           //   result: NIL (of QOut())
                                       // displays: 02/08/06
      bBlock := {|x,y| x + y }

      ? Eval( bBlock, 5, 17 )          // result: 22

      ? Eval( bBlock, "A", "string" )  // result: Astring
   RETURN

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