Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper 5.2 . The Guide To CA-Clippe - <b>eval()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 EVAL()
 Evaluate a code block
------------------------------------------------------------------------------
 Syntax

     EVAL(<bBlock>, [<BlockArg list>]) --> LastBlockValue

 Arguments

     <bBlock> is the code block to evaluate.

     <BlockArg list> is a list of arguments to send to the code block
     before it is evaluated.

 Returns

     EVAL() returns the value of the last expression within the block.  A
     code block can return a value of any type.

 Description

     EVAL() is a code block function.  It is the most basic code block
     evaluation facility in the CA-Clipper system.  A code block is a special
     data value that refers to a piece of compiled program code.  For more
     information on code blocks, refer to the Basic Concepts chapter in the
     Programming and Utilities guide.

     To execute or evaluate a code block, call EVAL() with the block value
     and any parameters.  The parameters are supplied to the block when it is
     executed.  Code blocks may be a series of expressions separated by
     commas.  When a code block is evaluated, the returned value is the value
     of the last expression in the block.

     The CA-Clipper compiler usually compiles a code block at compile time.
     There are, however, occasions at runtime, when you may need to compile a
     code block from a character string.  You can do this by using the macro
     operator (&).

     EVAL() is often used to create iterator functions.  These are functions
     that apply a block to each member of a data structure.  AEVAL(),
     ASORT(), ASCAN(), and DBEVAL() are iterator functions (e.g., AEVAL()
     applies a block to each element within an array).

 Examples

     .  This example creates a code block that increments a number
        then evaluates it:

        bBlock := { |nArg| nArg + 1 }
        ? EVAL(bBlock, 1)                     // Result: 2

     .  This example demonstrates compiling a code block at runtime
        using the macro operator (&):

        // Compile a string to a block
        bBlock := &("{ |nArg| nArg + 1 }")

        // Evaluate the block
        ? EVAL(bBlock, 1)

 Files:  Library is CLIPPER.LIB.

See Also: AEVAL() ASCAN() ASORT() DBEVAL()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson