Essential ABL elements
- Last Updated: May 30, 2019
- 3 minute read
- OpenEdge
- Version 13.0
- Documentation
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— TheUSINGstatement 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— TheCLASSstatement 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, theINHERITSoption 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.clsfile starting with anINTERFACEstatement. 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— ThePUBLICaccess 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,VOIDindicates that the method does not return a value:METHOD PUBLIC VOID addRecord( ): ... END METHOD. -
PROTECTED— ThePROTECTEDaccess 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— ThePRIVATEaccess 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 (.por.w), aCONSTRUCTORis 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 theNEWfunction. A constructor is named the same as the class. For example:CONSTRUCTOR PUBLIC PurchaseOrderForm( ): ... END CONSTRUCTOR. -
DESTRUCTOR— TheDESTRUCTORis a code block that is executed when a class-based object is deleted, either as a result of garbage collection or by using theDELETE OBJECTstatement. This block is analogous to anON 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— TheMETHODis 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— TheNEWfunction 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 itsPUBLICandPROTECTEDdata members, methods, and properties. All classes in ABL (including .NET classes) have the root super classProgress.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-OBJECTis useful as a qualifier when the class member reference name is a reserved ABL keyword. The primary use ofTHIS-OBJECTis to pass a reference of the current object to another routine and to improve readability. For example:THIS-OBJECT:Display( ). -
VALID-OBJECT— TheVALID-OBJECTfunction returnsTRUEif the object reference points to a valid ABL or .NET object instance. For example:VALID-OBJECT(MyObjectRef). -
CAST— TheCASTfunction 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).