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 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 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.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.