PreviousHeader-to-COPY Utility Concurrency SupportNext"

Chapter 13: Application Configuration System

The Application Configuration System enables programs to use a standard configuration technique to control their behavior.

13.1 Overview

A mechanism for configuring program information reduces the need for program changes, or extensive coding, to allow for variations in execution requirements.

The Application Configuration System (or Mfconfig program) was developed for use by the development environment. For example, on DOS, Windows and OS/2 the Application Configuration System is used to set the colors shown on the development environment menus.

The Application Configuration System can also be used by your programs.

The Application Configuration System is one of the integration tools. These are programs that provide facilities to quickly create menu systems to integrate your applications. The other integration tools documented with this product are: Banner, Directory Facility, Help, Linein, On-line Help System, Menu Handler, and Setup.


Note: The integration tool Setup, available in COBOL systems for DOS, Windows and OS/2 systems is not available in COBOL systems for UNIX.


The Application Configuration System is based on a file which holds the configuration information. This file is a standard text file which can be created and edited using the COBOL Editor, or other editors. Each program that uses the Application Configuration System can share the same file. Tags are used to identify information belonging to a particular program so that the addition of other information will not affect its behavior. The Application Configuration System simply parses this file and returns the relevant information to the calling program.

13.2 Operation

You use the Application Configuration System by creating a file to contain the configuration information and then calling the configuration program, Mfconfig, to read the information.

13.2.1 Configuration File Location

The configuration file can reside in any directory. You specify the path and filenames when you make a call to the Mfconfig program. If you don't, the default file is called mftools.cfg and can be found in the path specified in the COBDIR environment variable (COBDIR indicates the paths where the COBOL system files are installed).

13.2.2 One File and Several Programs

Configuration information is held in a simple text file. Several applications can place configuration information in the same text file even though they may have completely unrelated functions.

DOS, Windows and OS/2:
On DOS, Windows and OS/2, the development environment uses the configuration file: mf.ini.

UNIX:
On UNIX, the development environment uses the configuration file: mfcobolrc.

These configuration files include information for the following programs:

13.3 Configuration File Structure

The configuration file must be a line sequential file with a maximum record length of 255 characters.

The file is divided into sections by tags. A tag is a string of text that relates the data following it to a particular program. Each tag is unique and appears only once in the file. Tags can start in any column of the configuration file. All lines following a tag must be related to that tag until the next tag is found.

Tags and comment lines are defined with special characters or indicators. You can define your own indicators or use the defaults. If you need to use the indicator character in a sense where it should not be treated as an indicator, then an escape character "\" (backslash), can be used to ignore any special meaning given to the character immediately following it.

13.3.1 Tag Indicators

You can specify the symbol which is to be used to indicate tags. This can be either a single symbol which precedes the tag, or a pair of symbols which enclose the tag.

The default tag indicator is square brackets [ ].

If you want to specify the tag indicator, then this must be done in the first line of the configuration file and must be in one of the following formats:

TAG-INDICATOR: s

where s is the symbol to be used, or:

TAG-INDICATOR: s  t

if the tags are to be enclosed between symbols s and t.

You are advised to use non-alphabetic/non-numeric characters as tag indicators. For example, to use quotation marks to indicate a tag, specify:

TAG-INDICATOR " 

or, to use braces to indicate a tag, specify:

TAG-INDICATOR { } 

TAG-INDICATOR must be specified in upper-case characters.

13.3.2 Tags

The recommended format for the parameters in the tag section is:

parameter: value

Tags can have any format. However, since many programs can use tags in the same file, it is good practice to make sure the tags you use will be unique.

DOS, Windows and OS/2:
On DOS, Windows and OS/2, the development environment components that use the configuration system usually prefix their tags with "MF-" or "PROCO-".

UNIX:
On UNIX, the development environment components that use the configuration system usually prefix their tags with "MF-" or "MFC-".

Prefixing the tag with your program name might be a standard you should implement.

13.3.2.1 System Attributes Tag

There are 16 system attributes which can be defined in the configuration file to colorize your applications .

The attribute specification will be different according to whether you want to set attributes for a color screen or a monochrome screen. The following sections describe the colorization options for color and monochrome screens.

13.3.2.1.1 Color Screen Specification

The format of an attribute specification for a color screen is:

attribute-name: foreground ON background [BLINK]

For example:

SYS-ATT-11: Brown ON Black 

where words can be in mixed case. The naming convention is to use the system attribute name where each attribute is termed SYS-ATT-n, where n is a number between 1 and 16. These names correspond to the names used on the menu when you are setting colors as follows:

SYS-ATT-1 Reserved
SYS-ATT-2 Reserved
SYS-ATT-3 Menu-text
SYS-ATT-4 Key-tops
SYS-ATT-5 Tell-tales
SYS-ATT-6 Lock-on
SYS-ATT-7 Animated-text
SYS-ATT-8 Error-messages
SYS-ATT-9 Reserved
SYS-ATT-10 Margins
SYS-ATT-11 Normal-text
SYS-ATT-12 Current-line
SYS-ATT-13 Reserved
SYS-ATT-14 Reserved
SYS-ATT-15 Reserved
SYS-ATT-16 Reserved

The following colors can be used for either foreground or background:

BLACK
BLUE
GREEN
CYAN
RED
MAGENTA
BROWN
LIGHT-GREY

and the following colors can be used in addition for foreground only:

DARK-GREY
LIGHT-BLUE
LIGHT-GREEN
LIGHT-CYAN
LIGHT-RED
LIGHT-MAGENTA
YELLOW
WHITE

The colors can be entered in mixed case, but must be spelled as above for the system to be correctly colorized. If a foreground or background color is missing or invalid, the color of that attribute will default to BLACK.

You can also use the attribute BLINK on a color terminal. If included, it causes any text defined in the particular attribute to flash on and off.

13.3.2.1.2 Monochrome Screen Specification

The format of an attribute specification for a monochrome screen is:

attribute-name:{NORMAL       } [HIGHLIGHT] [BLINK]
               {INVISIBLE    }
               {REVERSE-VIDEO}

For example:

SYS-ATT-08: NORMAL HIGHLIGHT

The following attributes can be specified for a monochrome screen:

NORMAL
UNDERLINE
REVERSE-VIDEO
BLINK
HIGHLIGHT
INVISIBLE

BLINK and HIGHLIGHT are optional and can be included together or separately.

You can have a mixture of monochrome and color attribute specifications in your configuration file. Only those relevant to the screen type of the machine you are running on will have any effect during the initialization phase.

13.3.3 Comment Indicators

You can specify the symbol which is to be used to indicate comments in the configuration file. If you want to change the comment tag from the default from the beginning of the file, it must go in the first line of the file (or the second if a tag specification line is present). If the comment indicator line is specified elsewhere in the file, it must immediately follow a tag indicator line and it only indicates comments within that tag.

If there is no comment indicator line immediately following a tag, then the comment indicator specified at the start of the file (or the default if none is specified) is used within that tag.

The default comment indicator is the semicolon (;).

A line specifying the comment indicator takes the following format:

COMMENT-INDICATOR: c

where c is the symbol to be used for comments. You are advised to use non-alphabetic/non-numeric characters. For example, * or !. The word COMMENT-INDICATOR must be in upper-case.

All the lines with the comment indicator in column 1 are treated as a comment. All the lines with this symbol in any other column are processed up to the comment indicator. All blank lines are treated as comments.

If you need to use the comment indicator in a position where it should not be treated as a comment indicator, you can use the escape character ("\") to achieve this. So \; (backslash followed by semicolon) is a semicolon without being a comment.

13.3.4 Example Configuration Files

The configuration file used by your environment is present on your system and can be used as an example for other configuration files.

The example configuration file given in Example 1 shows the possible entries for system colorization. The example configuration file given in Example 2 shows how you include tag and comment indicators.

Example 1

This example is used, among other things, to colorize an environment and to set up the logging of environment functions.

Following are two of the sections from the configuration file:

[MF-CMENU] 
LOGGING:OFF

The Menu Handler calls the Application Configuration System with a tag of MF-CMENU and returns the record following the tag. From this, the Menu Handler determines whether or not to log the Environment functions.

[MF-ATTRIBUTES]
SYS-ATT-1:BLACK ON BLACK
SYS-ATT-2:YELLOW ON RED
SYS-ATT-3:BROWN ON BLACK
SYS-ATT-4:YELLOW ON BLACK
SYS-ATT-5:LIGHT-CYAN ON BLACK
SYS-ATT-6:WHITE ON BLACK
SYS-ATT-7:CYAN ON BLACK
SYS-ATT-8:WHITE ON BLACK BLINK
SYS-ATT-10:YELLOW ON RED
SYS-ATT-11:BROWN ON BLACK 
SYS-ATT-12:YELLOW ON BLACK 
SYS-ATT-1:INVISIBLE 
SYS-ATT-2:REVERSE-VIDEO 
SYS-ATT-3:NORMAL 
SYS-ATT-4:NORMAL HIGHLIGHT 
SYS-ATT-5:UNDERLINE 
SYS-ATT-6:UNDERLINE HIGHLIGHT 
SYS-ATT-7:NORMAL 
SYS-ATT-8:NORMAL HIGHLIGHT BLINK 
SYS-ATT-10:REVERSE-VIDEO 
SYS-ATT-11:NORMAL 
SYS-ATT-12:NORMAL HIGHLIGHT

This section of the configuration file is called by the executable files on startup to determine the colors for the environment. The section above shows the default colors for both a monochrome and color screen. The calling program determines whether or not the record is of the correct syntax for the terminal on which it is being run.

DOS, Windows and OS/2:
For further details on the build procedure which creates the Professional COBOL executable file ( proco.exe), see your Object COBOL User Guide.

Example 2

A second example of a configuration file is the following file which is designed to show as many of the different functions as possible:

TAG-INDICATOR: # 
COMMENT INDICATOR: ; 
; This is a comment which should not be returned
#TAG-1 
COMMENT INDICATOR: * 
LINE 1      *COMMENT 
LINE 2 
* Another comment 
LINE 3 
LINE 4 
     *  Another comment 
LINE 5 
#TAG-2 
LINE A 
LINE B;     Yet another comment 
LINE C 
#TAG-3 
; First a comment 
THEN A LINE TO RETURN WITH 2 \; IN \; IT 
; so the line of text returned is "THEN A LINE TO RETURN WITH 2 ;  IN ; IT" 
; Then another comment

The actual records that are returned to the program from this configuration file are:

LINE 1 
LINE 2 
LINE 3 
LINE 4 
LINE 5 
LINE A 
LINE B 
LINE C 
THEN A LINE TO RETURN WITH 2 ; IN ; IT

13.4 Call Interface

The program which parses the configuration file and returns to its calling program all of the text lines which are relevant to that component is called Mfconfig. It is contained within tools.lbr.

13.4.1 Parameters

The call to Mfconfig should be coded as shown. Each parameter is relevant for input or output as indicated. All text parameters used when calling Mfconfig should be in the ASCII character set.

call "mfconfig" using   function            (input)
                        return-status       (output)
                        component-tag       (input)
                        lcomponent-record   (output)
                        config-filename     (input)

where the parameters are:

function A PIC X COMP-X data item containing a code indicating the action to be performed. Available functions are:
0 Find tag area and return first record.
1 Return next tag area record.
2 Close the configuration file.
128 Find tag area and return first record and its length.
129 Return next tag area record and its length.
See the section Processing Method for details on how Mfconfig processes the configuration file using the different values for this parameter.
return-status A PIC X COMP-X data item. The status code returned to the calling program indicating the success or otherwise of the call. Possible status codes are:
0 Success, and buffer contains a string if function = 0 or 1
1 End of tag related lines (no record is returned and the record area contains the next tag in the configuration file).
2 The tag field passed to Mfconfig was empty; no text is returned.
3 The tag indicator symbol is invalid.
4 The comment indicator symbol is invalid.
5 Invalid tag found in configuration file (for example, first half of a two-part tag.
10 Invalid function supplied.
11 Configuration file closed.
128 Tag not found in configuration file.
253 File locked.
254 Configuration file not found.
255 Other file error.
component-tag A PIC X(32) data item. The tag-name. This tells Mfconfig which lines to return.
lcomponent-record A group item consisting of:
length A PIC X COMP-X data item. The length of the component-record. You should enter the length before the CALL statement. On exit, functions 128 and 129 contain the length of the returned record.
component-record A PIC X(n) data item where n is defined in the calling program. This contains the lines of text corresponding to the component tag in the configuration file and must be less than or equal to 255 bytes.
config-filename A PIC X(65) data item. Optional data item which contains the name of the configuration file. The default file is called mftools.cfg and can be found in the path specified by the COBDIR environment variable. The default filename and path are used if no config-filename parameter is passed to Mfconfig or if the parameter is blank. If a filename, but no path, is specified then a search path of the current directory followed by the COBDIR environment variable is used. If the configuration file specified does not exist then an error is returned to the calling program.

13.4.2 Processing Method

When it is first called with a value of 0 in the function field, Mfconfig reads the first line of the configuration file. If this contains a tag indicator then the indicator is set to this value, otherwise it is set to the default of square brackets.

Mfconfig then sets the comment indicator either to the value specified in the configuration file or to the default semicolon. It then reads sequentially through the configuration file until it finds a line with the tag specified. The next record is returned to the calling program, unless it contains another tag, and the status code set to 0.

Subsequent calls to Mfconfig with the following values in the function field, cause Mfconfig to process the configuration file as follows:

1 Causes the subsequent records to be returned, one by one, to the calling program until a new tag is found in the file. When the next tag is found, a status code of 1 is returned to the calling program.
2 Causes Mfconfig to close the currently open configuration file, if successful returning a status of 11.

If an error is found in the configuration file, then a suitable error status is returned to the calling program and the return code is set to 1. The errors recorded are:

2 The tag field passed to Mfconfig was empty - no text is returned.
3 The tag indicator symbol is invalid.
4 The comment indicator symbol is invalid.
5 Invalid tag (the first half of a two part tag).
10 Invalid function-on-entry supplied.
128 Tag not found in configuration file.
253 File locked.
254 Configuration file not found.
255 Other file error.

You can close the configuration file by calling Mfconfig with a value of 2 in the function field.


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

PreviousHeader-to-COPY Utility Concurrency SupportNext"