Create a class instance
- Last Updated: November 16, 2020
- 1 minute read
- OpenEdge
- Version 13.0
- Documentation
You can use any one of the following four ABL elements to create an instance of a class:
-
NEWfunction -
NEWstatement -
DYNAMIC-NEWstatement -
New( )method of theProgress.Lang.Classclass
At run time, the given function, statement, or method locates
the specified class type on the PROPATH using the
package information in the class type name (or as specified in an
appropriate USING statement at compile time) and
invokes the specified constructor to create a new instance of the
class. The NEW function returns an object reference
to the class instance (class-based object) it creates, which you
can use directly in an expression to access a member of the class
without assigning the object reference to a variable. The NEW statement
and the DYNAMIC-NEW statement each instantiate
the class and assign its object reference to a variable in a single
operation. The New( ) method of the Progress.Lang.Class class
returns an object reference to the instantiated class as a Progress.Lang.Object.
The basic difference between them is that the DYNAMIC-NEW statement
and the New( ) method allow you to instantiate
the class from information evaluated at run time, while both the NEW statement
and NEW function require that you specify the class
type using a type name that is resolved at compile time. The New( ) method
also provides the flexibility of using run-time information obtained
through reflection to specify the class and constructor parameters
(if any) that it uses to instantiate the class.