Special Purpose Operators

From Recital Documentation Wiki
Revision as of 14:38, 24 March 2009 by Yvonnemilne (Talk | contribs)

Jump to: navigation, search

Three special operators exist within the Recital/4GL. These are:

The Macro Operator (&)

When an ’&’ ampersand character precedes a variable or an expression contained within parentheses, the result of the expression is substituted into the command. Nested macros are not supported.

The Alias Operator (->)

An open table can be referred to by its alias name and its fields can be accessed using the alias operator. The alias name is either a name you have specified in the USE ALIAS <alias name> command, or, by default, the first ten characters of the table basename. The letters a-z (excluding m) can also be used as an alias to the work areas 1-26 (excluding 13). M is used to reference memory variables, so is not available as a table alias

The Dot Operator (.)

The dot operator ’.’ is used to reference either the properties of objects, or it can be used interchangeably with the alias operator.


Example

// Macro Operator Example
cTABLE = [employees]
use &cTABLE
 
// Alias Operator Example
cEMPNAME = &(cTABLE + "->NAME")
 
// Dot Operator Example
use employees
 
class EmpRecord
  public:
property NAME
property SALARY
  public:
method IDENT
return "Employee Record"
endclass
 
oMYREC = new EmpRecord()
cTYPE = oMYREC.IDENT()
? cTYPE