Version 6.3.13 for Windows
 —  Statements  —

CREATE OBJECT

CREATE OBJECT   operand1 OF  [CLASS]   operand2
   [ON [NODE] operand3]
   [GIVING operand4]

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.

When a CREATE OBJECT statement is executed on Windows platforms, Natural checks if the name of the class specified in the statement is registered as a DCOM class. If this is the case, it creates the object using DCOM. If this is not the case, it searches for a class with that name in the current Natural library or in the steplibs and creates the object locally.

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 C S       A                         yes no
operand4   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.

For further information, see the section Registration with Natural.

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

As operand3 you specify the node where the object is created. This is only possible if the class is registered as a DCOM class.

If the node clause is specified, an attempt is made to create the object on that node.

If the node clause is not specified or contains a blank value, the object is created on the node that is specified in the system registry under the key RemoteServerName for that class. If this registry key is not specified, the object is created in the local Natural session. For example

CREATE OBJECT #O1 OF CLASS "Employee" ON NODE "volcano.iceland.com"
GIVING operand4
GIVING Clause:

If this clause is specified, operand4 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