PreviousCalling Procedural COBOL from Java OLE Automation and DCOMNext

Chapter 3: Using Other Object Domains

Object COBOL enables you to send and receive messages to and from objects, using other object models.

Object COBOL provides a separate domain for objects accessed through each object model, and an Object COBOL program can access objects from several different domains. The objects accessed through a domain can be written in another language, and can be running in a separate process, although this is not always the case.

3.1 Overview

The different types of object model available through Object COBOL provide different levels of functionality. Each object model is represented by a different domain, and the support for each domain always consists of the following minimum:

Some object models provide additional services; these are documented for the specific object models.

3.2 Generic Domain Support

The following sections document the parts of domain support that are the same across all object models:

3.2.1 Identifying Objects from Different Domains

When you want to access a server object in a different domain, you need to identify the domain where it will be found. You do this through the Class-Control paragraph.

     COBOL-classname class is "$domain-name$class-name"

where the parameters are:

COBOL-classname The name by which the class is known to this COBOL program.
domain-name The name of the domain for the object.
class-name The name by which the class is known to the domain. This is usually determined by the name under which the class has been registered with the object model for that domain.

The example code below identifies two class objects, CharacterArray and Excel. CharacterArray is a native Object COBOL object, Excel is an OLE automation server, identified by $OLE$.

    CharacterArray is class "chararry"
    Excel is class "$OLE$excel.application"

To start using an instance of Excel, you send the OLE automation server the "new" message:

invoke excel "new" returning anExcelServer

This instantiates the OLE automation server; you can now send messages to anExcelServer.

3.2.2 Sending Messages to an Object in a Different Domain

Once you have identified a class as being in a different domain, you can send messages to it using the INVOKE verb. There is no difference in syntax between using INVOKE to communicate with an Object COBOL object, and in communicating with an object running in a different domain.

Not all COBOL datatypes are supported across different domains though, so parameters may be converted to a different format before being sent with the message. Data casting rules are documented separately for each domain.

Particular message selectors may have special meanings to different domains. For example, message selectors prefixed with "get" and "set" are automatically converted to property set or get operations in the OLE domain. These rules are also documented separately for each domain.

Copyright © 2000 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousCalling Procedural COBOL from Java OLE Automation and DCOMNext