Explicitly Linking Connection Libraries

Required Steps for Linking Libraries

To explicitly link two libraries, you must assign appropriate library attributes to each library, code an appropriate LINKLIBRARY function for the requesting library, and code a READYCL function for the responding library.

Order of LINKLIBRARY and READYCL Functions

Either the LINKLIBRARY function or the READYCL function can be executed first. If the LINKLIBRARY function is executed first, then the requesting library program might be delayed while the system waits for the responding library to execute the READYCL function.

Assigning Connection Library Attributes

For linkage to occur, you must assign library attributes to both the requesting and the responding libraries. However, different library attributes are required in each case.

Attributes for the Requesting Library

The following attributes of the requesting library affect linkage. For descriptions of these and other library attributes, refer to Using Library Attributes later in this section.

Library Attribute

Value and Meaning

LIBACCESS

Specifies how the system is to search for the code file of the responding library. The following are the possible values and their meanings:

  • BYTITLE

    The responding library code file is searched for by the value stored in the TITLE library attribute.

  • BYFUNCTION

    The responding library code file is searched for by the value stored in the FUNCTIONNAME library attribute.

  • BYINITIATOR

    The requesting library must be part of a process that was either initiated by another library process, or initiated by the library linkage mechanism after being invoked by another library. In either case, the BYINITIATOR value causes the requesting library to be linked to the library that originally initiated this instance of the requesting library.

FUNCTIONNAME

If LIBACCESS = BYFUNCTION, specifies the SL function name of the responding library code file. If FUNCTIONNAME is not explicitly assigned, it defaults to the value stored in the INTNAME library attribute.

TITLE

If LIBACCESS = BYTITLE, specifies the title of the library code file. If TITLE is not explicitly assigned, it defaults to the value stored in the INTNAME library attribute.

INTERFACENAME

Specifies which connection library to use in the code file of the responding library. It must match the INTERFACENAME value of the responding library.

The INTERFACENAME values must match, even if the responding library program contains only one connection library and regardless of whether the LIBACCESS value is BYTITLE, BYFUNCTION, or BYINITIATOR.

If INTERFACENAME is not explicitly assigned, it defaults to the value stored in the INTNAME library attribute.

The INTERFACENAME value is used only for implicit and explicit linkages; it is ignored for direct linkages.

Linking Connections to Different Libraries

To cause the various connections of the requesting library to link to different responding libraries, you must vary these library attributes in one of the following ways:

  • By specifying substitute values for library attributes in the LINKLIBRARY function. You can specify values for FUNCTIONNAME, TITLE, or INTERFACENAME in this function.

  • By assigning different library attributes to the requesting library before each LINKLIBRARY invocation.

Attributes for the Responding Library

The following attributes of the responding library affect linkage. For detailed descriptions of these and other library attributes, refer to Using Library Attributes later in this section.

LIBACCESS, FUNCTIONNAME, and TITLE are not used for linkage attempts when this library is the responding library. For INTERFACENAME, a different INTERFACENAME value should be assigned to each connection library in the responding connection library program, so that each library has a unique identification. When a requesting library attempts to link to a responding library, the system selects the responding library with an INTERFACENAME value matching that of the requesting library.

If INTERFACENAME is not explicitly assigned, it defaults to the value stored in the INTNAME library attribute.

Note: The preceding attributes are ignored for direct linkages.

Attribute Assignment Examples

The following are examples of attribute assignments in ALGOL:

SERVER_CL_TYPE LIBRARY SERVER_CL(CONNECTIONS = 10,
                                 LIBACCESS = BYFUNCTION,
                                 INTERFACENAME = “SECONDLINK.”);

LIBRARY (SERVER_CL).CONNECTIONS := 10;
LIBRARY (SERVER_CL).LIBACCESS := VALUE(BYFUNCTION);
REPLACE LIBRARY(SERVER_CL).INTERFACENAME BY “SECONDLINK.”;

Using LINKLIBRARY for the Requesting Library

LINKLIBRARY Parameters

You can use the LINKLIBRARY function to explicitly initiate linkage of the requesting connection library to another connection library. The LINKLIBRARY function can include the following parameters:

Parameter

Description

Connection Library Specifier

For non-SINGLE connection libraries, the connection library specifier can include a connection index. Alternatively, you can use the APPROVAL procedure to select the connection.

Note that the index specifies only the connection to use in the requesting library. The requesting library cannot anticipate, and does not need to know, what connection index of the responding library it will be linked to. The requesting library connection links to an unused connection index in the responding library, unless the responding library has an APPROVAL procedure that specifies a particular connection index.

DONTWAIT/ DONTWAITFORFILE/ WAITFORFILE Option

This option indicates the action to take if the matching library is not available. The following are possible values of this option and their effects:

  • DONTWAIT

    The linkage attempt proceeds only if a library instance is immediately available (that is, already frozen or readied by the READYCL function). Otherwise, LINKLIBRARY returns an error result.

  • DONTWAITFORFILE

    If a library instance is not available, the system initiates a new instance of the library code file. If the library code file is also not available, LINKLIBRARY returns an error result.

  • WAITFORFILE

    The linkage attempt continues regardless of whether a library instance or library code file is available. If a library instance is not available, the system initiates a new instance of the library code file. If the library code file is also not available, the linking process is suspended with an RSVP message and waits for an operator response.

Attribute Values

Substitute values for any of the following library attributes: FUNCTIONNAME, INTERFACENAME, or TITLE. These values temporarily override any values previously specified for these attributes.

Required Versus Optional Parameters

Of these parameters, only the connection library specifier is required. The DONTWAIT/ DONTWAITFORFILE/ WAITFORFILE parameter and the library attribute values are optional.

LINKLIBRARY Result

LINKLIBRARY returns a result indicating whether the linkage attempt was successful or not. The possible LINKLIBRARY results are documented in the ALGOL Programming Reference Manual, Volume 1: Basic Implementation.

LINKLIBRARY Example

The following ALGOL program fragment declares a connection library and then executes a LINKLIBRARY function to initiate linkage to another connection library:

EBCDIC ARRAY ARR[0:35];
REAL RSLT;

TYPE CONNECTION BLOCK TEST1;
   BEGIN
   PROCEDURE PROC2;
      BEGIN
      % Procedure body statements
      END;
   EXPORT PROC2;
   END;

TEST1 EXPORTING LIBRARY CL1 (LIBACCESS = BYTITLE, TITLE = 
“OBJECT/CLTEST.”,
                   CONNECTIONS = 3);

REPLACE ARR BY “CLTEST.”;
RSLT:= LINKLIBRARY (CL1[0], WAITFORFILE, INTERFACENAME = ARR);

In this example, the LINKLIBRARY function attempts to link connection 0 of CL1 to the library with an INTERFACENAME of CLTEST in the connection library program OBJECT/CLTEST. If program OBJECT/CLTEST is not available, then this process is suspended with an RSVP message.

In response to the LINKLIBRARY function, the system initiates OBJECT/CLTEST, if necessary. Then the system waits for OBJECT/CLTEST to ready connection library CLTEST. Thereafter, the system can complete the linkage.

Using READYCL for the Responding Library

READYCL Compared to FREEZE

For the responding connection library, the READYCL function indicates that the export objects in the connection library are now available. Thus, READYCL serves a purpose roughly similar to that of a FREEZE statement in a server library. However, unlike the FREEZE statement, the READYCL function never halts execution of the connection library program. Nor does the READYCL function offer any equivalent to the PERMANENT, TEMPORARY, and CONTROL options of the FREEZE statement.

READYCL Syntax

Unlike the LINKLIBRARY function, the READYCL function applies to the whole connection library instead of to a single connection. READYCL also returns a real value as a result. Thus, for a connection library named CL1 and a real variable named RSLT, the following ALGOL statement could be used:

RSLT:= READYCL (CL1);

READYCL Result

Field [15:16] of the return value stores the result of the operation. A zero indicates success. Odd numbers are errors, which indicate that the function failed. Even numbers are reserved for future use. The possible READYCL results are documented in the ALGOL Programming Reference Manual, Volume 1: Basic Implementation.

READYCL Example

The following statements in OBJECT/CLTEST declare library CL1 and ready it.

TYPE CONNECTION BLOCK TEST1;
   BEGIN
   PROCEDURE PROC2;
      IMPORTED;
   PROCEDURE PROC1;
      BEGIN
      % Procedure body statements
      END;
   EXPORT PROC1;
   END;

REAL RYRSLT;

TEST1 SINGLE LIBRARY CL2 (INTERFACENAME=“CLTEST.”);

RYRSLT:= READYCL (CL2);

In the preceding example, the READYCL function makes it possible for another connection library to be linked to this one.

Reversing a READYCL Action

You can reverse the effects of the READYCL function by using the UNREADYCL function, as discussed in Unreadying a Connection Library.