Invoking Methods

You also use dot notation to execute methods. Follow the reference to the object with a period, then with the method name and any parameters the method takes. The format is generally:

Object.method();

You can string methods and property values together into one statement. The following example strings together the GetField method with the Name property:

If &REC_BASE.GetField(&R).Name = &REC_RELLANG.GetField(&J).Name Then

Some methods return a Boolean value: True if the method executes successfully; False if it does not. The following method compares all like-named fields of the current record object with the specified record. This method returns as True if all like-named fields have the same value:

If &MYRECORD.CompareFields(&OTHERRECORD) Then 

Other methods return a reference to an object. The GetCurrEffRow method returns a row object:

&MYROW = &MYROWSET.GetCurrEffRow();

Some methods do not return anything. Each method's documentation indicates what it returns.

Many objects have default methods. Instead of entering the name of the method explicitly, you can use that method's parameters. Objects with default methods are composite objects; that is, they contain additional objects within them. The default method is generally the method used to get the lower-level object.

A good example of a composite object is a record object. Record definitions are composed of field definitions. The default method for a record object is GetField.

The following lines of code are equivalent:

&FIELD = &RECORD.GetField(FIELD.EMPLID);
&FIELD = &RECORD.EMPLID;

Note:

If the field you’re accessing has the same name as a record property (such as NAME) you cannot use the shortcut method for accessing the field. You must use the GetField method.

Another example of default methods concerns rowsets and rows. Rowsets are made up of rows, so the default method for a rowset is GetRow. The two specified lines of code are equivalent: They both get the fifth row of the rowset:

&ROWSET = GetRowSet();

/*the next two lines of code are equivalent */

&ROW = &ROWSET.GetRow(5);
&ROW = &ROWSET(5);

The following example illustrates the long way of enabling the Name field on a second-level scroll area (the code is executing on the first-level scroll area):

GetRowset(SCROLL.EMPLOYEE_CHECKLIST).GetRow(1).
GetRecord(EMPL_CHKLST_ITM).GetField(FIELD.NAME).Enabled = True;

Using default methods enables you to shorten the previous code to the following:

GetRowset(SCROLL.EMPLOYEE_CHECKLIST)(1).EMPL_CHKLST_ITM.NAME.
Enabled = True;

Expressions of the form class.name.property or class.name.method(..) are converted to a corresponding object. For example, the code &temp = RECORD.JOB.IsChanged; is evaluated as if it were &temp = GetRecord(RECORD.JOB).IsChanged;.

Furthermore, the code JOB.EMPLID.Visible = False; is evaluated as if it were GetField(JOB.EMPLID).Visible = False;.