| System Functions |
|
| Formats | 1.
Create Object: NEW(class$[,param1[$],
param2[$],...] [ FOR dependancy
][,ERR=stmtref]
) 2. Clone Object: NEW(obj_id [ FOR dependancy ][,ERR=stmtref] ) Where:
|
|||||||||||||||||
| Returns | Object Identifier. | |||||||||||||||||
| Description | The
NEW( ) function is used in Object
Oriented Programming to create a new object
based on a specified class name or an existing object (obj_id).
If the class name already exists, then its definition is
used. If it has not been defined previously, the system
attempts to load the program class.pvc and
execute/define the DEF CLASS within it
(the DEF CLASS clause must be at the
start of the program). If the system is unable to
properly determine the class definition, an Error
#90:"Unable to locate Object class definition"
is generated. In the example below, if the class definition for Customer does not already exist in memory, then the system attempts to load the program Customer.pvc: Cst = NEW ("Customer") If this is successful, the NEW( ) function returns the object identifier assigned to the object. The label ON_CREATE is called to initialize the object (if ON_CREATE logic exists in the class definition). Optional parameters can also be used with the NEW( ) function to be passed on to the ON_CREATEentry point; e.g., C = NEW("Customer", File_number) In Customer.pvx: 0010 ON_CREATE: ENTER File_no |
|||||||||||||||||
| *Note* | Use REF( ) to increment the reference count. | |||||||||||||||||
| Dependancies | The
OOP interface included in PxPlus has been enhanced to
allow for the automatic linking of objects to other
system components, such as, Programs, Windows, Controls,
Files and other Objects. As these other components are
closed or deleted, its linked objects will automatically
have their usage count decremented. Potentially, the
linked objects could also be freed up. This feature allows programmers to leave much of the housekeeping logic related to objects up to the system, as opposed to having to worry about coding for it themselves. By linking objects to items such as the current window, the programmer no longer needs to worry about dropping the object when the window is deleted. To establish this linkage the NEW function has been enhanced to include a "FOR" option where the programmer can specify the component that will be linked to the object.
Where:
|
|||||||||||||||||
| See Also | Object Oriented Programming DEF CLASS Directive REF( ) Function |
|||||||||||||||||