Language Elements and Reference:xpplrm

Alias operator Foundation

The alias operator is made up of the characters -> and serves to explicitly reference memory variables, field variables, or work areas. The alias operator is used when working with files managed by a database engine. Many files can be opened at the same time. Access to different files is managed using work areas. Only one database (a DBF file, for example) along with its index files can be opened in a work area. Work areas are selected using the SELECT command or they are addressed using an alias name or a numeric value. The alias operator, which must be preceded by the desired alias name, serves this purpose.

Alias names are specified when the file is opened. There are also two generic alias names: MEMVAR and FIELD. These are used to explicitly reference dynamic variables or field variables.

************** 
PROCEDURE Main 

   PRIVATE Name := "Alaska Software" 

   ? Name                         // result: Alaska Software 
   Proc1() 

RETURN 

*************** 
PROCEDURE Proc1 

   ? Name                         // result: Alaska Software 

   USE Address                    // open file via DatabaseEngine 

   ? FIELD->Name                  // result: Miller 
   ? MEMVAR->Name                 // result: Alaska Software 
   USE 

RETURN 

After the file is opened using the command USE in the procedure Proc1, two undeclared dynamic variables exist having the same identifier Name. Such a situation should generally be avoided, but it allows the effect of the alias operator and alias names to be demonstrated. The alias operator in one case refers to the field variable Name and in the other case to the memory variable Name. The alias name MEMVAR can be abbreviated as M. Instead of the alias name FIELD, the alias name of the file can be used. The alias name is identical to the file name unless an alias name is specified for the work area when the file is opened. The procedure Proc1 could also be written as:

************** 
PROCEDURE Main 

   PRIVATE Name := "Alaska Software" 

   ? Name                          // result: Alaska Software 
   Proc1() 

RETURN 

*************** 
PROCEDURE Proc1 

   ? Name                          // result: Alaska Software 

   USE Address                     // open file via DatabaseEngine 

   ? Address->Name                 // result: Miller 
   ? M->Name                       // result: Alaska Software 
   USE 

RETURN 

In this example, using the alias operator guarantees that the field variable always references the work area having the alias name Address, regardless of whether this work area is currently selected as the active area. The expression M->Name is merely an abbreviation for the explicit reference to the memory variable Name. The primary use of the alias operator is working with files and it is described in more detail in the discussion of database operations.

Feedback

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.