ABL supports two models for managing objects which provide access to a variety of capabilities:
  • Handle-based objects
  • Class-based objects

Handle-based objects

Handle-based objects represent built-in object types in ABL that you reference using weakly-typed object handles. These objects provide access to a variety of ABL capabilities, via their attributes and methods. You can define static or create dynamic instances of many handle-based object types. For example, the following program creates a socket object, attempts to connect to an identified resource and then deletes the object.

DEFINE VARIABLE hSocket AS HANDLE NO-UNDO.

/* Create socket and connect to server */

CREATE SOCKET hSocket.
                                                      
hSocket:CONNECT('-H localhost -S 23456') NO-ERROR.
IF hSocket:CONNECTED() = FALSE THEN
    DO:
        MESSAGE 'Unable to Connect' VIEW-AS ALERT-BOX.
        RETURN.
    END.

DELETE OBJECT hSocket.

In the example code you define a variable to be of type HANDLE. Then you create a socket object using the handle variable with the CREATE SOCKET statement. After creation, attributes and methods can then be called using the handle variable name, followed by a colon, and then the method or attribute name. In the example code, CONNECT and CONNECTED are methods that are called. After the object is no longer needed, DELETE OBJECT is called to clean up resources. Handle-based objects are not garbage collected. It is the responsibility of the application to delete them.

You can also chain handle references together to simplify coding. See Chained handle references for more detail.

Class-based objects

Class-based objects also represent built-in object types in ABL which you reference using strongly‑typed object handles. These objects provide access to a variety of capabilities, via their properties and methods. You can define static or create dynamic instances of class-based object types.

The following program creates a FileInputStream object and reads the first 50 bytes from file sample.data. The AVM deletes this object (via garbage collection) when no more references to the object exist.

USING Progress.IO.*.
DEFINE VARIABLE rFile AS CLASS FileInputStream NO-UNDO.
DEFINE VARIABLE mData AS MEMPTR NO-UNDO.

/* Create an instance of a FileInputStream object */
rFile = New FileInputStream ("sample.data").
                                                      
rFile:Read(mData, 0, 50).
rFile:Close( ).
See also

Handle Reference

Handle Attributes and Methods Reference

Class, Interface, and Enumeration Reference

Class Properties and Methods Reference.