Operator = (assignment) Foundation

Simple assignment (binary): assigns a value to a variable.

<VarName> = <Expression>
<VarName> designates a variable of any storage class or a member variable which is to be assigned the value. If <VarName> is not explicitly declared, a variable of storage class PRIVATE is created.
<Expression> is an expression resulting in a value of any data type, whose value is assigned to the variable <VarName>.

The simple assignment operator (=) assigns a value to a variable. The expression <Expression> on the right side of the operator is evaluated and the value is assigned to the variable <VarName>.

The simple assignment operator (=) differs from the inline assignment operator in that it cannot be used within an expression. Within an expression the operator is interpreted as a comparison operator which tests whether two expressions are equal. The simple assignment operator cannot initialize variables within variable declarations (this is only possible with the inline assignment operator).

The variable may belong to any storage class. If the variable is a field variable, valid field variable data types depend on the active database engine (DBE). Values of the data types array, code block, object or NIL cannot be used with the DBFDBE engine. For DBFDBE, only values with the data type character, numeric, logical or date can be assigned to field variables.

When an undeclared variable <VarName> is referenced and no explicit alias name is used, it is considered by the compiler to be of storage class MEMVAR unless a field variable of the same name exists at runtime. If the variable does not exist at runtime, it is created at runtime as a PRIVATE variable.

If, at the time of assignment, both a field variable and an undeclared memory variable exist with the same name (the same symbol), the default behavior is to assign the value to the field variable. This default behavior can be changed by using the compiler switch /V.

The simple assignment operator (=)
// This example illustrates various possibilities of a 
// simple assignment. 

   LOCAL nRow, nCol 

   nRow = 10                        // assignment to 
   nCol = MaxCol()                  // declared variables 

   cFile = "CUSTOMER.DBF"           // assignment to an 
                                    // undeclared variable 
   IF File(cFile) 
      USE (cFile) ALIAS Cust 

      MEMVAR->Name = Cust->Name     // assignment to an 
                                    // undeclared variable 

      Cust->Name = "Miller"         // assignment to a field variable 



If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.