Back to first page...

THE ENVIRONMENT DIVISION

This division is made up of two SECTIONS. The CONFIGURATION SECTION and the INPUT-OUTPUT SECTION.

The CONFIGURATION SECTION identifies the computer system that a program is coded and compiled on. It also identifies the "Object Computer", which is the computer on which the program will be eventually run. Remember, COBOL is a standard language; you can use a different computer to develop your pgm, than the one people will use your pgm on. These declarations are made by the SOURCE-COMPUTER and OBJECT-COMPUTER declaratives.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER. IBM 3090.
       OBJECT-COMPUTER. IBM PC, MS-DOS 6.
The INPUT-OUTPUT SECTION relates actual file names to COBOL names which synbolize these actual files within the program name.
       ENVIRONMENT DIVISION.

       CONFIGURATION SECTION.
       SOURCE-COMPUTER. IBM 3090.
       OBJECT-COMPUTER. IBM PC, MS-DOS 6.

       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
            SELECT STUDENT-FILE ASSIGN TO "STUFILE.DAT"
            SELECT PRINT-FILE ASSIGN TO PRINTER.
Note that SELECT statements start in zone B.

The SELECT PRINT-FILE statement associates a the default printer device of your computer to a internal file name "PRINT-FILE". Suppose one day you change your mind and decide to have all lines going to the printer be stored in a file instead. All you have to do is change the associated SELECT statement replacing the word "PRINTER" with a valid file name and recompile your pgm.

Another scenario : You find out that your default drive (say C:) does not have enough space to hold the STUDENT-FILE. All you have to do is to replace the "STUFILE.DAT" entry with "D:STUFILE.DAT" and recompile. You can be very very sure that there is no drive specification else where in your program except this SELECT statement. If you were using the C language you would have to go through ALL the source code and inspect all the "open", "close" statements for a drive specification.


Back to first page...