Using the In-line Configuration Facility

One of the most powerful features of the Client/Server Binding is the ability to control the communications requirements from configuration files. This does mean, however, that end-users can affect the way an application runs by changing entries in these files, and this may not be desirable.

It is possible, therefore, to provide all the configuration parameters within the client program. This means that the end-user cannot alter the way an application behaves because it no longer uses a configuration file. There is still no need to write complex communications code, you simply supply the required parameters within your client program. The process is started by setting load-inline-cfg and completed by setting end-inline-cfg. Each parameter entry is loaded into the lnk-error-msg field and mfclient is called to process it. The parameters have to be supplied before the main processing loop is entered. An example is given below.

In-line configuration is not supported when using AAI.

 WORKING-STORAGE SECTION.

  COPY "mfclisrv.cpy".

 LINKAGE SECTION.

 01 INPUT-REC                 PIC X(32767)

 PROCEDURE DIVISION.

 Client-Control SECTION.

     SET load-inline-cfg TO TRUE
     MOVE "clierrprog=same" TO lnk-error-msg
     CALL lnk-client USING lnk-param-block

     MOVE "srverrprog=same" TO lnk-error-msg
     CALL lnk-client USING lnk-param-block

     MOVE "servername=mainserv" TO lnk-error-msg
     CALL lnk-client USING lnk-param-block

     SET end-inline-cfg TO TRUE

*  The main loop is repeated until the connection with
*  the server ends

     PERFORM UNTIL End-Connection

*  'lnk-client' holds the name 'mfclient'
*  The first time through we initialize the system and 
*  establish contact with the server.

     CALL lnk-client USING lnk-param-block

     EVALUATE TRUE

      WHEN start-connection

      ........ The rest of the program is standard from this
      ........... point onwards  ............

It is also possible to combine an external configuration file with the in-line configuration facility. This provides the best of both worlds in that the end-user can modify the system to their own requirements, but ultimate control remains within the client program. The configuration file is processed first followed by the in-line entries. This means that any unwanted parameters supplied in the configuration file can be overwritten by the in-line entry. In this case the process is started by setting use-combined-cfg and completed as before by setting end-inline-cfg.

 WORKING-STORAGE SECTION.

 COPY "mfclisrv.cpy".

 LINKAGE SECTION.

 01 INPUT-REC                 PIC X(32767)

 PROCEDURE DIVISION.

 Client-Control SECTION.

     SET use-combined-cfg TO TRUE
     CALL lnk-client USING lnk-param-block

     SET load-inline-cfg TO TRUE
     MOVE "servername=mainserv" TO lnk-error-msg
     CALL lnk-client USING lnk-param-block

     SET end-inline-cfg TO TRUE

*  The main loop is repeated until the connection with
*  the server ends

     PERFORM UNTIL End-Connection

*  'lnk-client' holds the name 'mfclient'
*  The first time through we initialize the system and 
*  establish contact with the server.

     CALL lnk-client USING lnk-param-block

     EVALUATE TRUE
      WHEN start-connection

      ........ The rest of the program is standard from this
      ........... point onwards  ............