Return a set-get code block for a given memory variable

     MEMVARBLOCK(<cMemvarName>) --> bMemvarBlock


     <cMemvarName> is the name of the variable referred to by the set-get
     block, specified as a character string.


     MEMVARBLOCK() returns a code block that when evaluated sets (assigns) or
     gets (retrieves) the value of the given memory variable.  If
     <cMemvarName> does not exist, MEMVARBLOCK() returns NIL.


     The code block created by MEMVARBLOCK() has two operations depending on
     whether an argument is passed to the code block when it is evaluated.
     If evaluated with an argument, it assigns the value of the argument to
     <cMemvarName>.  If evaluated without an argument, the code block
     retrieves the value of <cMemvarName>.


     .  MEMVARBLOCK() creates set-get blocks only for variables whose
        names are known at runtime.  MEMVARBLOCK(), therefore, cannot be used
        to create set-get blocks for local or static variables.  The same
        restriction applies to creating blocks using the macro operator (&).


     .  This example compares MEMVARBLOCK() to a code block created
        using the macro operator (&).  Note that using MEMVARBLOCK() allows
        you to avoid the speed and size overhead of the macro operator:

        PRIVATE var := "This is a string"
        // Set-Get block defined using macro operator
        bSetGet := &( "{ |setVal|;
              IF( setVal == NIL, var, var := setVal ) }" )
        // Set-Get block defined using MEMVARBLOCK()

        // bSetGet created here is the functional
        // equivalent of bSetGet above
        bSetGet := MEMVARBLOCK("var")

 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.