[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 Evaluate a code block

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


     <bBlock> is the code block to be evaluated.

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


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


     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 iteration functions.  These are functions
     that apply a block to each member of a data structure.  AEVAL(),
     ASORT(), ASCAN(), and DBEVAL() are iteration functions (e.g., AEVAL()
     applies a block to each element within an array).


     .  This example creates a code block that increments a number,
        and 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)                     // Result: 2

 Files   Library is CLIPPER.LIB.

This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson