Operator -> Foundation

Alias operator (binary): selects a work area.

<AliasName> -> <FieldName>
<AliasName> -> (<Expression>)
(<nArea>)   -> <FieldName>
(<nArea>)   -> (<Expression>)
FIELD       -> <VarName>
MEMVAR      -> <VarName>
<AliasName> designates the alias name of a work area where a file previously opened with the command USE or the function DbUseArea() is available.
<nArea> is a numeric expression which indicates the ordinal position of the work area that is to be selected.
<FieldName> designates the name of a field variable which exists in the work area specified with <AliasName> or <nArea>.
<Expression> is any expression which is to be executed in the indicated work area. If the expression is not a name for a field variable, it must be enclosed in parentheses.
<VarName> designates the name for a memory variable or a field variable which can be referenced with one of the two standard alias names MEMVAR or FIELD (respectively). The alias name MEMVAR can only be used for memory variables which are of storage class PRIVATE or PUBLIC. LOCAL and STATIC variables cannot be referenced with the alias operator. The alias FIELD always indicates a field variable in the current work area.

The alias operator -> explicitly selects a work area (in which a file is open) and then evaluates the expression. On the left side of the operator should be either the alias name of the work area or a numeric value in parentheses indicating the ordinal position of the desired work area. On the right side of the operator is either the name of a field variable or an expression enclosed in parentheses. The alias operator implicitly uses the command SELECT, which selects a work area. After the evaluation of the expression on the right side of the operator the original work area is restored as the current work area.

In Xbase++ there are two reserved alias names FIELD and MEMVAR, which are used with undeclared variables to specify to the compiler that they are field variables or memory variables which are of storage class PRIVATE or PUBLIC. These two alias names exist for compatibility reasons and their use is not recommended. Instead, declaring or explicitly associating each variable with a work area is highly recommended.

When an undeclared variable in a procedure or user defined function can indicate either a memory variable or a field variable, the field variable is accessed by default. This default behavior can be changed by the compiler switch /V.

The alias operator (->)
// This example demonstrates the various syntax 
// possibilities of the alias operator. 

  LOCAL nCustArea, nInvArea 

   USE Customer NEW 
   INDEX ON Name TO Customer 
   USE Invoices ALIAS Inv NEW 
   nCustArea := Customer->(Select()) 
   nInvArea := Inv->(Select()) 

   SELECT 100                       // select empty work area 

   ? Customer->Name                 // result: Miller 
   ? Customer->(Eof())              // result: .F. 

   ? (nInvArea)->(Eof())            // result: .F. 

   Inv->(DbAppend())                // create new record 

   REPLACE Inv->CustomerNr ;        // data copied from work area 
       WITH (nCustArea)->CustomerNr // (numeric) to work area (Alias) 

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.