Declaring a Connection Library

Connection Blocks

To declare a connection library, you must first declare a connection block. The connection block is a type declaration that acts as a model for the definition of one or more connection libraries. The following ALGOL statements define a connection block called CL_TYPE and two different connection libraries that are based on this connection block:

TYPE CONNECTION BLOCK CL_TYPE;
   BEGIN
   REAL PROCEDURE PROC1;
      BEGIN
      % Procedure body statements
      END;
   EXPORT PROC1;
   END;

CL_TYPE SINGLE EXPORTING LIBRARY CL_ONE (INTERFACENAME=“CLTESTLIB1.”);

CL_TYPE EXPORTING LIBRARY CL_TWO (INTERFACENAME=“CLTESTLIB2.”,
                        CONNECTIONS=3);

Connection Libraries Based on the Same Connection Block

The actual connection libraries are CL_ONE and CL_TWO. These two libraries are completely separate and independent of each other. Nevertheless, the two libraries do follow a common pattern. Hence, CL_ONE and CL_TWO each export a procedure called PROC1. To create connection libraries that contain different procedure declarations, you must base the connection libraries on separate connection blocks.

Multiple Connections of the Same Connection Library

Each connection library supports one or more connections. A connection is used to establish a linkage between a connection library and another connection library.

Examples of Single and Multiple Connections

In the previous example, library CL_ONE can support only one connection, because CL_ONE is declared with the keyword SINGLE. The CONNECTIONS attribute cannot be increased by later assignment statements.

By contrast, library CL_TWO initially supports up to 3 connections, because the SINGLE keyword is omitted and the CONNECTIONS library attribute is set to 3. The use of 3 connections enables CL_TWO to link to up to 3 other connection libraries. Further, because the SINGLE keyword is omitted, the CONNECTIONS attribute can be increased by later assignment statements.

Numbering of Connections

The numbering of connections is zero-relative. Thus, a CONNECTIONS value of 3 enables the use of connections numbered 0 through 2.

One-Way Connections

The connections defined in these examples only export data. The EXPORTING keyword is used to specify this and to ensure that this library is only used in one-way connections. Using the EXPORTING or IMPORTING keyword eliminates your ability to do two-way data sharing in this program, but has the significant advantage of helping to ensure that library delinkage does not become an application performance problem.