Declare private and public variable names

     MEMVAR <idMemvar list>


     <idMemvar list> is a list of public and private variable names to
     declare to the compiler.


     MEMVAR is a declaration statement that causes the compiler to resolve
     references to variables specified without an explicit alias by
     implicitly assuming the memory variable alias (MEMVAR->).  Only
     explicit, unaliased references to the specified variables are affected.
     MEMVAR, like all declaration statements, has no effect on references
     made within macro expressions or variables.

     The MEMVAR statement neither creates the variables nor verifies their
     existence.  Its primary effect is to ensure correct references to
     variables whose existence is known to be guaranteed at runtime.  At
     runtime, the specified variables must be created using the PRIVATE,
     PARAMETERS or PUBLIC statements.  This can occur in the procedure
     containing the MEMVAR declaration or in a higher -level procedure.
     Attempting to access the variables before they are created will cause an

     The scope of the MEMVAR declaration is the procedure or function in
     which it occurs, or the entire source file if it precedes any PROCEDURE
     or FUNCTION statements and the /N compiler option is used.  The /N
     option suppresses automatic definition of a procedure with the same name
     as the program (.prg) file.

     Like other declaration statements, MEMVAR must precede any executable
     statements, including PARAMETERS, PUBLIC, and PRIVATE statements in a
     procedure or function definition, or the program (.prg) file if the
     declaration has filewide scope.

     MEMVAR can be used in conjunction with the /W compiler option--which
     generates warning messages for ambiguous variable references--to perform
     compile--time checking for undeclared variables.

     For more information on variable declarations and scoping, refer to the
     Variables section in the "Basic Concepts" chapter of the Programming and
     Utilities Guide.


     .  This example demonstrates the relationship between a private
        and field variable with the same name.  The private variable is
        declared with the MEMVAR statement:

        FUNCTION Example
           MEMVAR amount, address
           PRIVATE amount := 100
           USE Customer NEW
           ? amount                // Refers to amount private variable
           ? Customer->Amount      // Refers to Amount field variable
           RETURN NIL


3 responses to “C5_MEMVAR

  1. Pingback: Variable Handling | Viva Clipper !

  2. Pingback: C5 Statements | Viva Clipper !

  3. Pingback: C5_PRIVATE | Viva Clipper !

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.