Operator := Foundation

Inline assignment (binary): assigns a value to one or more variables.

<VarName> := <Expression>
<VarName> designates a memory variable of any storage class or a member variable which is to be assigned a value. If <VarName> is not explicitly declared, a variable of the 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 inline assignment operator (:=) assigns a value to one or more variables. The expression <Expression> on the right side of the operator is evaluated and the value is assigned to the variable <VarName>. The result of the operation is the assigned value.

The inline assignment operator differs from the simple assignment operator (=) in that it can be used to make an assignment within an expression. It can be used in a variable declaration to assign an initial value to a variable. Also, several variables can be assigned the same value in a single program line.

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

When the variable <VarName> is referenced but is undeclared, and an explicit alias name is not used, it is considered by the compiler to be of storage class MEMVAR. If the variable does not exist, 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 inline assignment operator (:=)
// This example illustrates various possibilities of an 
// inline assignment. 

   LOCAL nRow:=0, nCol:=0           // assignment in declaration 
   LOCAL aArray[10]                 // no assignment possible 
   LOCAL cFile, n1, n2, n3 

   IF File(cFile := "CUSTOMER.DBF") // assignment in an expression 
      USE (cFile) ALIAS Cust        // (before calling function) 

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

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

   n1 := n2 := n3 := 100            // multiple assignment 


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.