Try OpenEdge Now
skip to main content
GUI for .NET Primer
Object-oriented Programming in ABL : Essential ABL elements
 

Essential ABL elements

The OpenEdge GUI client provides access to .NET forms (analogous to ABL WINDOW widgets) and controls using object-oriented extensions to ABL. Using ABL, you create forms, add controls, access data, subscribe to events and write event handlers for .NET controls. Accessing and using .NET objects is very similar to working with ABL objects using classes, however, there are some exceptions, due to the differences between supported constructs in .NET and ABL.
The following are examples of ABL elements that are used when working with .NET forms and controls:
*USING — The USING statement makes code easier to read and less verbose by allowing you to abbreviate the full class or object type name in code. For example:
USING Progress.Windows.Form.
USING System.Windows.Forms.*.
USING Infragistics.Win.UltraWinListView.*.
*CLASS — The CLASS statement defines a user-defined class, representing a user-defined data type. Its characteristics are defined by a set of data members, including properties, that define class data and methods that define class behavior. For example:
CLASS MyUserControl:
  ...
END CLASS.
*INHERITS — When defining a class, the INHERITS option specifies the super class whose state and behavior this class inherits. For example:
CLASS MyUserControl INHERITS Progress.Windows.UserControl:
  ...
END CLASS.
*IMPLEMENTS — Classes can implement one or more interfaces, each of which are defined as a separate .cls file starting with an INTERFACE statement. An interface declares a common public mechanism to access behavior that one or more classes can define, even though these classes do not inherit from another common class. Interfaces allow you to define and manage common behavior that might be implemented differently in different classes and for different purposes. For example:
CLASS MyUserControl IMPLEMENTS IUpdatable:
  ...
END CLASS.
*PUBLIC — The PUBLIC access mode specifies that the object, code block, or data member can be accessed by the defining class, any of its inheriting classes, and any class or procedure that instantiates that class (through an object reference), or has access to the object reference. In this example, VOID indicates that the method does not return a value:
METHOD PUBLIC VOID addRecord( ):
  ...
END METHOD.
*PROTECTED — The PROTECTED access mode specifies that the object, code block, or data member can be accessed by the defining class and any of its inheriting classes. An instance can access a protected member of a second instance that is at the same level or in a super class in the class hierarchy. For example:
DEFINE PROTECTED VARIABLE cName AS CHARACTER NO-UNDO.
*PRIVATE — The PRIVATE access mode specifies that the object, code block, or data member can be accessed by the defining class. An instance can access the private member of another instance if both instances are from the same class. For example:
DEFINE PRIVATE VARIABLE bindSrc1 AS Progress.Data.BindingSource NO-UNDO.
*CONSTRUCTOR — Similar to a Main Block in an ABL structured procedure (.p or .w), a CONSTRUCTOR is a block that is executed when a class-based object is instantiated. A constructor of a class is a special method that is called when a class is instantiated, for example, using the NEW function. A constructor is named the same as the class. For example:
CONSTRUCTOR PUBLIC PurchaseOrderForm( ):
  ...
END CONSTRUCTOR.
*DESTRUCTOR — The DESTRUCTOR is a code block that is executed when a class-based object is deleted, either as a result of garbage collection or by using the DELETE OBJECT statement. This block is analogous to an ON CLOSE OF THIS-PROCEDURE DO: block in a persistent procedure. A destructor is named the same as the class. For example:
DESTRUCTOR PUBLIC PurchaseOrderForm( ):
  ...
END DESTRUCTOR.
*METHOD — The METHOD is a code block that provides class behavior. Methods are similar to internal procedures and user-defined functions, in that they encapsulate object behavior. For example:
METHOD PRIVATE VOID InitializeComponent( ):
  ...
END METHOD.
*NEW — The NEW function creates an instance of a class and returns an object reference to that instance. The new or derived class is a subclass of its super class parent, inheriting its PUBLIC and PROTECTED data members, methods, and properties. All classes in ABL (including .NET classes) have the root super class Progress.Lang.Object. For example:
DEFINE VARIABLE bindSrc1 AS Progress.Data.BindingSource NO-UNDO.
bindSrc1 = NEW Progress.Data.BindingSource( ).
*THIS-OBJECT — An object reference to the class instance currently running. THIS-OBJECT is useful as a qualifier when the class member reference name is a reserved ABL keyword. The primary use of THIS-OBJECT is to pass a reference of the current object to another routine and to improve readability. For example:
THIS-OBJECT:Display( ).
*VALID-OBJECT — The VALID-OBJECT function returns TRUE if the object reference points to a valid ABL or .NET object instance. For example:
VALID-OBJECT(MyObjectRef).
*CAST — The CAST function returns a new object reference to the same class instance as an existing object reference, but with a different data type. The underlying object does not change, but the reference to it has changed. For example:
CAST(MyObjectRef, MySubClass).