New( ) method
- Last Updated: January 18, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Instantiates a class whose class type and any
parameters are known only at run time. This method returns a Progress.Lang.Object,
which provides an instance of a class. The New( ) method
provides similar functionality to the DYNAMIC-NEW function. The
advantage to the latter is that it has a fixed, compile-time parameter
list and does not require the creation of a Progress.Lang.ParameterList object
at run time.
Return type: Progress.Lang.Object class
Access: PUBLIC
Applies to: Progress.Lang.Class class
The class type to instantiate is specified by the TypeName property of the applicable
Progress.Lang.Class instance.
Syntax
Two overloaded versions are supported. The first version is used when the constructor of the class does not take any arguments.
|
You can use the second overloaded version of
the New( ) method when the constructor
of a class takes zero or more parameters. Since a parameterlist-object can
be built with zero or more parameters, this version of the New( ) method
can be used to instantiate any class, even those classes whose constructor
does not take any arguments.
|
- parameterlist-object
- An instance of the
Progress.Lang.ParameterListclass. The instance contains an entry for each parameter required by the constructor being invoked. It is valid to pass aProgress.Lang.ParameterListobject with zero parameters if the class constructor does not take any parameters. If one or more parameters are passed, theProgress.Lang.ParameterList:SetParameter( )method must have been previously called on each parameter.The AVM raises a run-time error if the Unknown value (
?) is passed for parameterlist-object.
Notes
- Since the
New( )method returns an instance of theProgress.Lang.Objectclass, the result of theNew( )method must be assigned to aProgress.Lang.Objectobject. - The
New( )method must be coded in a standalone Assignment (=) statement and not as part of an ASSIGN statement. - For information on any restrictions, such as types of .NET objects you can instantiate, see the reference entry for the DYNAMIC-NEW statement.
See also
Clear( ) method (Class), DYNAMIC-INVOKE function, DYNAMIC-NEW statement, Invoke( ) method (Class), NEW function (classes), NEW statement, NumParameters property (ParameterList), Progress.Lang.ParameterList class, SetParameter( ) method (Class)