Speaker notes to accompany SCREENS (Screens using DISPLAY/ACCEPT in COBOL):

Slide #1:

This presentation deals with adding color and other features to screens in COBOL. The program will write the output using the DISPLAY/ACCEPT that we have covered.

Slide #2:

This program is if88scr1.cbl. It deals with if statement using level 88s and displays the information on the screen in the format shown.

Note the background color of the screen and the font are set in the program. The different font for the total is also handled in the program.

Slide #3:

You will see this in the context of the program on later slides.

I have now associated these colors with DISPLAY-LINE so anytime I want to display on the screen, I will move the information that I want to display to DISPLAY-LINE and then I will issue the statement DISPLAY DISPLAY-LINE. I will specify the line and column where I want the first letter of the display to appear.

Slide #4:

Level 88 condition names let the programmer give a name to a condition. The condition of TYPZ = "L" is named TYPE-LIFE by using the level 88. Similarly, the condition TYPZ = "C" is named TYPE-CAR and the condition TYPZ = "H" is named TYPE-HOME.

Slide #5:

Note that you only need to define the colors you want to use in your program. I defined all of the colors for reference.

This slide also shows the display line which is the line that I will display on the screen. Whatever I want to display will be moved to the area called DISPLAY-LINE and then DISPLAY-LINE will be displayed on the screen.

One more thing...

This slide also shows a condition name associated with the indicator MORE-RECS. The condition END-OF-FILE is testing whether MORE-RECS = "NO ".

Slide #6:

This part of the program shows the work area, the accumulator, the page number and the line count as well as a place to store the system date.

The detail line is the line that contains the information on a particular person.

Note that DETAIL-LINE will be moved to DISPLAY-LINE and then DISPLAY-LINE will be displayed on the screen. It will show the contents of the DETAIL-LINE that was moved to it just prior to the display.

Slide #7:

Note that in this portion of the program, I am setting up the page header which will receive the parts of the system date and the page number. I am also setting up the column header.

The total line is also shown here. I will move the accumulator to the total line prior to displaying it.

Note that all of these lines will be moved to DISPLAY-LINE prior to displaying on the screen.

Slide #8:

This is the beginning of the PROCEDURE DIVISION where the control of the program is shown.

Slide #9:

Notice that I do not have to give a number for LINE. I can use a dataname or variable. Whatever the value of LINE-CT-WS is, that is where the line will be written.

Slide #10:

Since I am always going to DISPLAY DISPLAY-LINE, I have to move the DETAIL-LINE that I want to DISPLAY to the DISPLAY-LINE prior to issuing the DISPLAY command.

Again remember, IF TYPE-LIFE is the same as saying IF TYPZ = "L".

Slide #11:

This routine does the DISPLAY DISPLAY-LINE but makes a change to the foreground color prior to writing.

Slide #12:

This writes the headers and then adds 1 to the page number so there will not be another header until the line count is greater than 10.

Note the other code that goes with the display line that was explained earlier.

The program: IF88SCR1.CBL:

       IDENTIFICATION DIVISION.
       PROGRAM-ID.  SAMPLEIF.
       AUTHOR.  GROCER.
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT INS-FILE
               ASSIGN TO "A:\INS.DAT".
       DATA DIVISION.
       FILE SECTION.
       FD  INS-FILE
           DATA RECORD IS INS-REC.
       01  INS-REC.
           05  IDNO       PIC XXXX.
           05  NAMZ       PIC X(20).
           05  TYPZ       PIC X.
               88  TYPE-LIFE              VALUE "L".
               88  TYPE-CAR               VALUE "C".
               88  TYPE-HOME              VALUE "H".
           05  AMT-COV    PIC 9(7)V99.
           05  PREM-YR    PIC 9(4)V99.
       WORKING-STORAGE SECTION.
       01  MICROFOCUS-COLORS  PIC 99.
      *THESE COLORS CNA BE USED FOR FOREGROUND AND BACKGROUND.
           78  BLACK                            VALUE 0.
           78  BLUE                             VALUE 1.
           78  GREEN                            VALUE 2.
           78  CYAN                             VALUE 3.
           78  RED                              VALUE 4.
           78  MAGENTA                          VALUE 5.
           78  BROWN                            VALUE 6.
           78  WHITE                            VALUE 7.
      *THHESE COLORS CAN BE USED FOR FOREGROUND ONLY.
           78  BRIGHT-BLACK                     VALUE 8.
           78  BRIGHT-BLUE                      VALUE 9.
           78  BRIGHT-GREEN                     VALUE 10.
           78  BRIGHT-CYAN                      VALUE 11.
           78  BRIGHT-RED                       VALUE 12.
           78  BRIGHT-MAGENTA                   VALUE 13.
           78  BRIGHT-BROWN                     VALUE 14.
           78  BRIGHT-WHITE                     VALUE 15.
      *NOTE THAT LEVEL 78 IS A STANDALONE DATANAME CODED AS SHOWN.
       01  DISPLAY-LINE       PIC X(80).
       01  INDICATORS.
           05  MORE-RECS      PIC XXX           VALUE "YES".
               88  END-OF-FILE                  VALUE "NO ".
           05  ANS-WS         PIC X             VALUE SPACES.
       01  WORK-AREAS.
           05  PREM-MO-WS     PIC 999V99        VALUE 0.
       01  ACCUMULATORS.
           05  TOT-MO-PREM-WS PIC 9(5)V99       VALUE 0.
       01  PAGE-CONTROL.
           05  PAGE-NO-WS     PIC 99            VALUE 1.
           05  LINE-CT-WS     PIC 99            VALUE 0.
           05  DATE-WS.
               10  YR-WS      PIC 99.
               10  MO-WS      PIC 99.
               10  DA-WS      PIC 99.
       01  DETAIL-LINE.
           05  FILLER         PIC X.
           05  IDNO-PR        PIC XXXX.
           05  FILLER         PIC XX.
           05  NAMZ-PR        PIC X(20).
           05  FILLER         PIC XX.
           05  TYPZ-MSG-PR    PIC X(13).
           05  FILLER         PIC XX.
           05  AMT-COV-PR     PIC $$,$$$,$$$.99.
           05  FILLER         PIC XX.
           05  PREM-MO-PR     PIC $$$$.99.
           05  FILLER         PIC X(14).
       01  PAGE-HDR.
           05  FILLER         PIC X       VALUE SPACES.
           05  DATE-HDR.
               10  MO-HDR     PIC 99.
               10  FILLER     PIC X       VALUE "/".
               10  DA-HDR     PIC 99.
               10  FILLER     PIC X       VALUE "/".
               10  YR-HDR     PIC 99.
           05  FILLER         PIC X(19)   VALUE SPACES.
           05  FILLER         PIC X(16)   VALUE "INSURANCE REPORT".
           05  FILLER         PIC X(18)   VALUE SPACES.
           05  FILLER         PIC X(5)    VALUE "PAGE".
           05  PAGE-NO-HDR    PIC Z9.
           05  FILLER         PIC X(13)    VALUE SPACES.
       01  COL-HDR.
           05  FILLER         PIC X(11)   VALUE " ID #  NAME".
           05  FILLER         PIC X(18)   VALUE SPACES.
           05  FILLER         PIC X(17)   VALUE "INSURANCE        ".
           05  FILLER         PIC X(13)   VALUE "   COVERAGE  ".
           05  FILLER         PIC X(15)   VALUE "MONTH PREM     ".
           05  FILLER         PIC X(6)    VALUE SPACES.
       01  TOTAL-LINE.
           05  FILLER         PIC X(56)   VALUE SPACES.
           05  TOT-MO-PREM-TL PIC $$$,$$$.99.
           05  FILLER         PIC X(14)    VALUE SPACES.
       PROCEDURE DIVISION.
       MAINLINE.
           PERFORM A-100-INITIAL.
           PERFORM B-100-PROCESS.
           PERFORM C-100-TERMINATE.
           STOP RUN.
       A-100-INITIAL.
           OPEN INPUT INS-FILE.
           ACCEPT DATE-WS FROM DATE.
           MOVE MO-WS TO MO-HDR.
           MOVE DA-WS TO DA-HDR.
           MOVE YR-WS TO YR-HDR.
       B-100-PROCESS.
           READ INS-FILE
               AT END
                   MOVE "NO " TO MORE-RECS.
           PERFORM B-200-LOOP
               UNTIL END-OF-FILE.
           PERFORM B-210-TOTAL-ROUT.
       B-200-LOOP.
           IF PAGE-NO-WS = 1
               PERFORM B-300-HDR-ROUT.
           IF LINE-CT-WS  10
               ADD 1 TO LINE-CT-WS
               MOVE "PRESS ANY KEY TO CONTINUE..." TO DISPLAY-LINE
               DISPLAY DISPLAY-LINE LINE LINE-CT-WS COL 1
               ACCEPT ANS-WS
               PERFORM B-300-HDR-ROUT.
           MOVE SPACES TO DETAIL-LINE.
           MOVE IDNO TO IDNO-PR.
           MOVE NAMZ TO NAMZ-PR.
           IF TYPE-LIFE
               MOVE "LIFE" TO TYPZ-MSG-PR
           ELSE
               IF TYPE-CAR
                   MOVE "AUTOMOBILE" TO TYPZ-MSG-PR
               ELSE
                   IF TYPE-HOME
                       MOVE "HOME OWNERS" TO TYPZ-MSG-PR
                   ELSE
                       MOVE "** INVALID **" TO TYPZ-MSG-PR.
           MOVE AMT-COV TO AMT-COV-PR.
           DIVIDE PREM-YR BY 12
               GIVING PREM-MO-WS ROUNDED.
           MOVE PREM-MO-WS TO PREM-MO-PR.
           ADD PREM-MO-WS TO TOT-MO-PREM-WS.
           MOVE DETAIL-LINE TO DISPLAY-LINE.
           DISPLAY DISPLAY-LINE AT LINE LINE-CT-WS COL 1.
           ADD 1 TO LINE-CT-WS.
           READ INS-FILE
               AT END
                   MOVE "NO " TO MORE-RECS.
       B-210-TOTAL-ROUT.
           ADD 1 TO LINE-CT-WS.
           MOVE TOT-MO-PREM-WS TO TOT-MO-PREM-TL.
           MOVE TOTAL-LINE TO DISPLAY-LINE.
           DISPLAY DISPLAY-LINE WITH
                   FOREGROUND-COLOR BRIGHT-RED LINE LINE-CT-WS COL 1.
       B-300-HDR-ROUT.
           MOVE PAGE-NO-WS TO PAGE-NO-HDR.
           MOVE PAGE-HDR TO DISPLAY-LINE.
           DISPLAY DISPLAY-LINE AT LINE 1 COL 1
               WITH BLANK SCREEN
               BACKGROUND-COLOR CYAN
               FOREGROUND-COLOR WHITE.
           MOVE COL-HDR TO DISPLAY-LINE.
           DISPLAY DISPLAY-LINE LINE 3 COL 1.
           ADD 1 TO PAGE-NO-WS.
           MOVE 5 TO LINE-CT-WS.
       C-100-TERMINATE.
           CLOSE INS-FILE.