xHarbour Reference Documentation > Function Reference |
Evaluates a code block.
Eval( <bBlock> [, <xValue,...> ] ) --> xReturn
The function returns the value of the last expression inside the code block.
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.
See also: | AEval(), AScan(), ASort(), DbEval(), FieldBlock() |
Category: | Code block functions , Indirect execution |
Source: | vm\evalhb.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// 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
http://www.xHarbour.com