Class-based data member access

References a data member of a class in order to read or write its value.

Syntax

[ [ class-type-name | object-reference ] : ] data-member-name 
   [[ index ]]
class-type-name
The name of an ABL or .NET class type that defines the specified data member as a static member. The use of class-type-name to access a static data member is optional when you access the data member from within the class hierarchy where it is defined. For more information, see the notes for this reference entry. You can use class-type-name only to access data members that can be defined as PUBLIC. For more information, see the notes for this reference entry. You cannot use class-type-name to access an instance data member. For more information on specifying class (object) type names, see the Type-name syntax reference entry. You also can use the unqualified class name with the presence of an appropriate USING statement.
object-reference
Specifies a reference to an instance of an ABL or .NET class (an object) that defines the specified data member as an instance member. The use of object-reference to access an instance data member is optional when you access the data member from within the class hierarchy where it is defined. For more information, see the notes for this reference entry.For more information, see the notes for this reference entry. You cannot use object-reference to access a static data member. For information on specifying object references, see the reference entry for a Class-based object reference.
data-member-name
The name of a data member you want to access. In .NET, a data member is referred to as a field. A data member is a data element that is defined in, and at, the level of a class definition (as distinct from a local data element that is defined in and at the level of a method definition). If it is an instance data member, a separate copy exists for each instance of its defining class, for as long as the class instance exists. If it is a static data member, only one copy exists for the defining class type for the entire ABL session, regardless if any instance of the class exists. A data member is available either inside or outside of the class hierarchy depending on its access mode.
[ index ]
Specifies the index to reference an element of an ABL array data member, where index is an integer value that identifies the element. The brackets are a required part of the index syntax.
Note: To access the elements of a .NET array object, you must use the .NET SetValue( ) and GetValue( ) methods on the array object instead. For more information on using these methods, see the Microsoft .NET Framework documentation and the Parameter passing syntax reference entry in this manual.

Examples

The following code fragment shows a reference to a public instance data member (hHighCustData) on an instance of the sample class, r-CustObj:

DEFINE VARIABLE rObj AS CLASS r-CustObj NO-UNDO.
rObj = NEW r-CustObj( ) NO-ERROR.

MESSAGE "Number of buffers =" rObj:hHighCustData:NUM-BUFFERS 
  VIEW-AS ALERT-BOX.

This instance data member is a handle to a ProDataSet that is used, in this case, to reference the NUM-BUFFERS attribute, which returns the number of buffers in the ProDataSet.

The following code fragment shows a reference to a public static data member (hHighCustData) on the sample class type, r-CustObjStatic:

MESSAGE "Number of buffers =" r-CustObjStatic:hHighCustData:NUM-BUFFERS 
  VIEW-AS ALERT-BOX.

This static data member is also a handle to a similar ProDataSet, and example code performs the same function as the previous instance code without having to instantiate a class.

For more information on these data members and the sample classes in which they are defined, see the examples in the CLASS statement reference entry.

Notes

See also

Class-based object reference, CLASS statement, Type-name syntax