xHarbour Reference Documentation > Operator Reference xHarbour Developers Network  

->

Alias operator (binary): identifies a work area.

Syntax

<aliasName>   -> <fieldName>
(<nWorkArea>) -> <fieldName>

 <aliasName>  -> ( <expr,...> )
(<nWorkArea>) -> ( <expr,...> )

FIELD  -> <fieldName>
MEMVAR -> <varName>

Arguments

<aliasName>
This is the symbolic alias name of a work area as specified with the ALIAS option of the USE command.
<fieldName>
The field name whose value is retrieved from the work area specified with <aliasName>.
<nWorkArea>
Instead of using a symbolic name, a work area can be identified by its numeric ordinal position <nWorkArea>. This value can be obtained by calling the Select() function. The numeric work area must be enclosed in parentheses () when using it with the alias operator.
<expr,...>
One or more comma separated expressions to execute in the work area identified with <aliasName> or <nWorkArea>.
FIELD
The FIELD keyword is a reserved alias name that identifies a field variable in the current work area.
MEMVAR
The MEMVAR keyword is a reserved alias name that identifies a memory variable of type PRIVATE or PUBLIC. An abbreviation of this alias is M->.

Description

The alias operator "points" to an unselected work area identified with its symbolic name <aliasName> or its ordinal number <nWorkArea>. This allows for retrieving values of field variables from unselected work areas or executing expressions in the specified work area. The alias operator implicitly selects the work area specified with the left operand and then executes the instructions of the right operand. When the operation is complete, the original work area becomes current again.

FIELD and MEMVAR are reserved alias names that allow for resolving name conflicts between memory and field variables. If memory and field variables with the same symbolic name exist, unaliased variables are resolved as field variables. This behaviour is influenced by the compiler switch /v. It is, however, strongly recommended to avoid identical variable names for memory and field vraiables, and to use the alias operator to identify a variable unambiguously.

Info

See also:DbSelectArea(), FIELD, FieldName(), FieldPos(), FieldGet(), MEMVAR, Select(), USE
Category: Special operators , Operators
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates usage of the alias operator.
// The last aliased expression generates a runtime error.

   PROCEDURE Main
      LOCAL nArea

      USE Customer ALIAS Cust          // current work area
      ? FIELD->Lastname                // result: Miller

      nArea := Select()                // work area number
      SELECT 100                       // select free work area
      ? Used()                         // result: .F.

      ? Cust->Lastname                 // result: Miller
      ? Cust->(Recno())                // result: 1

      ? (nArea)->Lastname              // result: Miller
      ? (nArea)->(LastRec())           // result: 1576

      ? FIELD->Lastname                // runtime error
      USE
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe