Handle-based and class-based objects
- Last Updated: October 29, 2020
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
- 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.
|
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.
|
Handle Attributes and Methods Reference