Previous Next

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 
*
*
*
*
*
*
*
*
From within an ABL class definition, you can reference any data member that is both defined and available within the class hierarchy using its data-member-name without a qualifying object-reference (for instance, data members) or class-type-name (for static data members). Data members that you can reference directly by data-member-name within the class hierarchy where they are defined include:
*
Available variables (and their associated visual widgets) that have a PRIVATE, PROTECTED, or PUBLIC access mode. You can use the THIS-OBJECT system reference as an object-reference to access any available instance variable data member that is defined within the class hierarchy. However, you must use THIS-OBJECT to access any instance variable data member whose name is a reserved keyword. You can also use class-type-name to access any available static variable data member that is defined within the class hierarchy. However, you must use class-type-name to access any static variable data member whose name is a reserved keyword.
*
*
*
From within a class hierarchy where static data members are defined, you can use a qualifying class-type-name to access only the static variable data members from both ABL and .NET, including the elements of arrays. To access all other static data members (such as temp-tables or buffers) defined in the current class hierarchy, you must only use an unqualified data-member-name.
*
From outside a class hierarchy, you must reference any available instance data member using its data-member-name qualified by an object-reference to the class instance where the data member is defined, and you must reference any available static data member using the class-type-name of the class where the data member is defined as static. The only data members that are available outside the class hierarchy where they are defined are variables defined as PUBLIC (and any associated visual widgets for instance variables), including the elements of arrays.
Note:
See also 
Class-based object reference, CLASS statement, Type-name syntax

Previous Next
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates.