Return a set-get code block for a given field

     FIELDBLOCK(<cFieldName>) --> bFieldBlock


     <cFieldName> is the name of the field to which the set-get block
     will refer.


     FIELDBLOCK() returns a code block that, when evaluated, sets (assigns)
     or gets (retrieves) the value of the given field.  If <cFieldName> does
     not exist in the specified work area, FIELDBLOCK() returns an empty


     FIELDBLOCK() is a database function that builds a code block.  When
     executed with an argument, the code block created by this function
     assigns the value of the argument to <cFieldName>.  When executed
     without an argument, the code block retrieves the value of <cFieldName>.

     Note that the specified field variable may not exist when the code block
     is created, but must exist before the code block is executed.


     .  Work area: The code block returned by FIELDBLOCK() sets or
        gets the value of the specified field in whatever work area is
        current when the block is run.  For example, given work areas 1 and
        2, both containing field FName:

     SELECT 1
        FName:= "Kate"
        SELECT 2

        FName := "Cindy"
        bFName := FIELDBLOCK("FName")
        SELECT 1
        ? EVAL(bFName)               // Result: "Kate"
        SELECT 2
        ? EVAL(bFName)               // Result: "Cindy"

        The function FIELDWBLOCK() provides a set-get block for a field in a
        specific work area.


     .  This example compares FIELDBLOCK() to a code block created
        using the macro operator.  Note that using FIELDBLOCK() avoids the
        speed and size overhead of the macro operator:

        // Set-Get block defined using macro operator
        bSetGet := &( "{ |setVal| IF( setVal == NIL,;
                        FName, FName := setVal ) }" )
        // Set-Get block defined using FIELDBLOCK()

        // bSetGet created here is the functional
        // equivalent of bSetGet above
        bSetGet := FIELDBLOCK("FName")

 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.