Natural for Mainframes Version 8.2.5 for Mainframes
 —  Statements  —

CREATE OBJECT

CREATE OBJECT operand1 OF [CLASS] operand2
   [GIVING operand3]

This document covers the following topics:

For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.

Related Statements: DEFINE CLASS | INTERFACE | METHOD | PROPERTY | SEND METHOD

Belongs to Function Group: Component Based Programming


Function

The CREATE OBJECT statement is used to create an instance of a class.

Top of page

Syntax Description

Operand Definition Table:

Operand Possible Structure Possible Formats Referencing Permitted Dynamic Definition
operand1   S                               O no no
operand2 C S       A                         yes no
operand3   S     N         I                 yes no

Syntax Element Description:

Syntax Element Description
operand1
Object Handle:

operand1 must be defined as an object handle (HANDLE OF OBJECT). The object handle is filled when the object is successfully created. When not successfully returned, operand1 contains the value NULL-HANDLE.

OF CLASS operand2
Class-Name:

operand2 is the name of the class of which the object is to be created. For classes that are not registered as DCOM classes, it must contain the class name defined in the DEFINE CLASS statement. For classes that are registered as DCOM classes, it must contain either the ProgID of the class or the class GUID. For Natural classes that are registered as DCOM classes, the ProgID corresponds to the class name specified in the DEFINE CLASS statement.

CREATE OBJECT #O1 OF CLASS "Employee" or
CREATE OBJECT #O1 OF CLASS "653BCFE0-84DA-11D0-BEB3-10005A66D231"
GIVING operand3
GIVING Clause:

If this clause is specified, operand3 contains either the Natural message number if an error occurred, or zero on success.

If this clause is not specified, Natural run time error processing is triggered if an error occurs.

Top of page