Compaq COBOL
User Manual


Previous Contents Index

11.3 Designing Video Forms with Screen Section ACCEPT and DISPLAY (Alpha)

The Screen Section feature provides an efficient alternative to the ACCEPT and DISPLAY extensions for designing video forms. Screen Section, which is based on the X/Open CAE Specification for COBOL, is also a Compaq extension to the ANSI Standard. It enables you to design video forms in a single section of your Compaq COBOL program. Then, in the Procedure Division, you can accept or display an entire screen of data with a single ACCEPT or DISPLAY statement, instead of multiple statements.

You can design your form as follows:

  1. In the SPECIAL-NAMES paragraph in the Environment Division, you can optionally do the following:
    For example:


    SPECIAL-NAMES. 
     
        CURSOR IS CURSOR-POSITION 
     
        CRT STATUS IS CRT-STATUS. 
    

  2. You can use the Screen Section in the Data Division to define a screen description entry to describe each input and output item within the video form. Do this for each screen in your application.
    For example:


    SCREEN SECTION. 
     
    01 MENU-SCREEN BLANK SCREEN FOREGROUND-COLOR 7 BACKGROUND-COLOR 1. 
       02 MENU-SCREEN-2. 
          03 TITLE-BAR 
             FOREGROUND-COLOR 7 BACKGROUND-COLOR 4. 
             04 LINE 1 PIC X(80) FROM EMPTY-LINE. 
             04 LINE 1 COLUMN 32 VALUE "Daily Calendar". 
    

    See Section 11.3.1 for a description of the options available in the Screen Section.

  3. Then you use the ACCEPT and DISPLAY statements in the Procedure Division with the screen description entries described in the Screen Section to accept or display each entire screen or part of the screen. During a DISPLAY, all output and update screen items are displayed. During an ACCEPT, all input and update screen items are accepted.
    For example:


        DISPLAY MENU-SCREEN. 
        .
        .
        .
        ACCEPT MENU-SCREEN. 
    

11.3.1 Using Screen Section Options (Alpha)

You design your screens with screen description entries in the Screen Section of the Data Division of your program. Three formats are available for a screen description entry (and are completely defined in the Data Division chapter of the Compaq COBOL Reference Manual):

Table 11-4 shows the optional clauses you can use in a screen description entry to specify character attributes, the formats to which they apply, and a summary of their functions. (They are completely described in the Data Division chapter of the Compaq COBOL Reference Manual.)

Table 11-4 Character Attribute Clauses for Screen Description Formats (Alpha)
Clause Formats Function
AUTO 1,3 Moves the cursor to the next field when the last character of a field is entered.
BACKGROUND-COLOR 1, 2, 3 Specifies by number (in the range 0--7) the screen item's background color (see the color list that follows).
BELL 2, 3 Sounds the audio tone on the workstation or terminal.
BLANK LINE 2, 3 Clears the line before displaying the screen item.
BLANK SCREEN 1, 2, 3 Clears the screen before displaying the screen item.
BLANK WHEN ZERO[ES] 3 Replaces zeros with spaces when a screen item's value is zero.
BLINK 2, 3 Causes the displayed item to blink.
COLUMN NUMBER 2, 3 Specifies the horizontal position of an item on the screen.
ERASE EOL 2, 3 Clears the line from the cursor position to the end.
ERASE EOS 2, 3 Clears the screen from the cursor position to the end.
FOREGROUND-COLOR 1, 2, 3 Specifies by number (in range 0--7) the screen item's foreground color. See the color list that follows.
FULL 1, 3 Specifies that a screen item must either be left completely empty or be entirely filled with data.
HIGHLIGHT 2, 3 Specifies that the field is to appear on the screen with the highest intensity.
JUSTIFIED RIGHT 3 Specifies nonstandard data positioning. This can cause truncation of the leftmost characters if the sending item is too large. Otherwise, this aligns the data at the rightmost character position.
LINE NUMBER 2, 3 Specifies the vertical position of an item on the screen.
LOWLIGHT 2, 3 Specifies that the field is to appear on the screen with the lowest intensity. If only two levels of intensity are available, LOWLIGHT is the same as normal.
REQUIRED 1, 3 Specifies that at least one character must be entered in the input or update field.
REVERSE-VIDEO 2, 3 Specifies that the foreground and background colors be exchanged.
SECURE 1, 3 Specifies that no characters are displayed when the input field is entered.
SIGN LEADING [SEPARATE] 1, 3 Specifies the existence of a sign character as the leading character in the field. The SEPARATE option is always in effect if the screen item has an 'S' in the PICTURE clause. Therefore, for a screen item, the sign character never shares its position with a digit.
SIGN TRAILING [SEPARATE] 1, 3 Specifies the existence of a sign character as the trailing character in the field. The SEPARATE option is always in effect if the screen item has an 'S' in the PICTURE clause. Therefore, for a screen item, the sign character never shares its position with a digit.
UNDERLINE 2, 3 Specifies that each character of the field is to be underlined when displayed.
USAGE DISPLAY 1, 3 Specifies the internal format of a data item as DISPLAY (the default).

When you specify the foreground and background colors for a screen item, you use numbers in the range 0--7, which represent specific colors as described in Table 11-5. Note that these colors are supported only on terminals that support ANSI Standard color sequences.1

Table 11-5 Color Table
Color Color Value Color Color Value
Black 0 Red 4
Blue 1 Magenta 5
Green 2 Yellow/Brown 6
Cyan 3 White 7

11.3.1.1 Comparison of Screen Section Extensions (Alpha) with Other Extensions of ACCEPT and DISPLAY

This section points out some of the major differences and similarities between the Screen Section and non-Screen Section extensions to help you determine which to use.

Similarities

There are significant similarities between the Screen Section feature and that of the non-Screen Section screen formats, as follows:

In a number of cases, a clause that you can use in the Screen Section of the Data Division, in the screen description entry, accomplishes the same purpose as a clause in the Procedure Division's ACCEPT or DISPLAY statement (in a non-Screen Section extended format). The difference is in the clauses' names (not interchangeable) and where you use them: in the Data Division's Screen Section, or in the Procedure Division with the ACCEPT or DISPLAY statement. The following table shows these clauses:
Screen Section Clause ACCEPT or DISPLAY Clause with Equivalent Effect
AUTO AUTOTERMINATE
BLANK LINE ERASE LINE
BLANK SCREEN ERASE SCREEN
BLINK WITH BLINKING
ERASE EOL ERASE TO END OF LINE
ERASE EOS ERASE TO END OF SCREEN
HIGHLIGHT BOLD
REVERSE-VIDEO REVERSED
SECURE WITH NO ECHO
UNDERLINE UNDERLINED

Differences

There are also significant differences between the Screen Section (Alpha) and the non-Screen Section screen formats. With the Screen Section:

Refer to Section 11.2, and also the Compaq COBOL Reference Manual Data Division chapter's section on Screen Description and clauses, for details on these features.

In Example 11-12 (Alpha only), a video form is designed for a daily calendar. With it you can display appointments, schedule new appointments, cancel appointments, and print appointments.

Example 11-12 Designing a Video Form for a Daily Calendar (Alpha)

IDENTIFICATION DIVISION. 
PROGRAM-ID. MENU. 
 
ENVIRONMENT DIVISION. 
CONFIGURATION SECTION. 
 
*   The SPECIAL-NAMES paragraph that follows provides for the 
*   capturing of the F10 function key and for positioning of the 
*   cursor. 
 
SPECIAL-NAMES. 
 
    SYMBOLIC CHARACTERS 
        FKEY-10-VAL 
    ARE 11         
 
    CURSOR IS CURSOR-POSITION 
 
    CRT STATUS IS CRT-STATUS. 
 
DATA DIVISION. 
WORKING-STORAGE SECTION. 
 
*   CURSOR-LINE specifies the line and CURSOR-COL specifies the 
*   column of the cursor position. 
 
01  CURSOR-POSITION. 
    02  CURSOR-LINE    PIC 99. 
    02  CURSOR-COL     PIC 99. 
 
*   Normal termination of the ACCEPT statement will result in a value 
*   of '0' in KEY1.  When the user presses F10, the value in KEY1 will 
*   be '1' and FKEY-10 will be true. 
 
01  CRT-STATUS. 
    03 KEY1            PIC X. 
    03 KEY2            PIC X. 
       88 FKEY-10      VALUE FKEY-10-VAL. 
    03 filler          PIC X. 
 
*   The following data items are for a "Daily Calendar."  It shows 
*   the day's appointments and allows appointments to be made, 
*   canceled, and printed. 
 
01 ACCEPT-ITEM1  PIC X. 
01 APPT-NAME     PIC X(160). 
01 APPT-DAY      PIC XX. 
01 APPT-MONTH    PIC XX. 
01 APPT-YEAR     PIC XX. 
01 APPT-HOUR     PIC XX. 
01 APPT-MINUTE   PIC XX. 
01 APPT-MERIDIEM PIC XX. 
01 APPT-VERIFY   PIC X. 
01 EMPTY-LINE    PIC X(80). 
 
*   The SCREEN SECTION designs the Daily Calendar, with a menu 
*   screen from which the user selects an option:  to show 
*   appointments, schedule an appointment, cancel an appointment, 
*   and print the appointments. 
 
SCREEN SECTION. 
 
01 MENU-SCREEN BLANK SCREEN FOREGROUND-COLOR 7 BACKGROUND-COLOR 1. 
   02 MENU-SCREEN-2. 
      03 TITLE-BAR 
         FOREGROUND-COLOR 7 BACKGROUND-COLOR 4. 
         04 LINE 1 PIC X(80) FROM EMPTY-LINE. 
         04 LINE 1 COLUMN 32 VALUE "Daily Calendar". 
 
      03 LINE 7  COLUMN 26 
         PIC X TO ACCEPT-ITEM1. 
      03 VALUE " Show appointments for a day ". 
      03 LINE 9  COLUMN 26 
         PIC X TO ACCEPT-ITEM1. 
      03 VALUE " Schedule an appointment ". 
      03 LINE 11 COLUMN 26 
         PIC X TO ACCEPT-ITEM1. 
      03 VALUE " Cancel an appointment ". 
      03 LINE 13 COLUMN 26 
         PIC X TO ACCEPT-ITEM1. 
      03 VALUE " Print your appointments ". 
      03 HELP-TEXT 
         FOREGROUND-COLOR 6 BACKGROUND-COLOR 0. 
        04 LINE 19 COLUMN 12 
           VALUE 
           " Use the arrow keys to move the cursor among menu items. ". 
        04 LINE 20 COLUMN 12 
           VALUE 
           " Press <Return> when the cursor is at the desired item.  ". 
        04 LINE 21 COLUMN 12 
           VALUE 
           " Press <F10> to exit.                                    ". 
 
01 SCHEDULE-SCREEN BLANK SCREEN. 
   02 TITLE-BAR 
      FOREGROUND-COLOR 7 BACKGROUND-COLOR 4. 
      03 LINE 1 PIC X(80) FROM EMPTY-LINE. 
      03 LINE 1 COLUMN 30 VALUE "Schedule Appointment". 
 
   02 FIELDS-TEXT 
      FOREGROUND-COLOR 7 BACKGROUND-COLOR 1. 
      03 LINE 5 VALUE " Description of Appointment: ". 
      03 LINE PLUS 4 VALUE " Date of Appointment (DD/MM/YY): ". 
      03 COLUMN PLUS 5 VALUE "/  /". 
      03 LINE PLUS 2 VALUE " Time of Appointment (HH:MM mm): ". 
      03 COLUMN PLUS 5 VALUE ":". 
 
   02 FIELDS-INPUT 
      FOREGROUND-COLOR 7 BACKGROUND-COLOR 0 AUTO. 
      03 LINE 6  PIC X(160) TO APPT-NAME. 
      03 LINE 9  COLUMN 36 PIC XX USING APPT-DAY. 
      03 LINE 9  COLUMN 39 PIC XX USING APPT-MONTH. 
      03 LINE 9  COLUMN 42 PIC XX USING APPT-YEAR. 
      03 LINE 11 COLUMN 36 PIC XX USING APPT-HOUR. 
      03 LINE 11 COLUMN 39 PIC XX USING APPT-MINUTE. 
      03 LINE 11 COLUMN 42 PIC XX USING APPT-MERIDIEM. 
 
   02 HELP-TEXT 
      FOREGROUND-COLOR 6 BACKGROUND-COLOR 0. 
      03 LINE 16 COLUMN 18 
         VALUE " Use Cursor Keys to move within the fields. ". 
      03 LINE 17 COLUMN 18 
         VALUE " Press <Tab> to enter next field.           ". 
      03 LINE 18 COLUMN 18 
         VALUE " Press <Return> when finished.              ". 
 
01 VERIFY-SUBSCREEN FOREGROUND-COLOR 7 BACKGROUND-COLOR 1. 
   02 LINE 16 COLUMN 1 ERASE EOS. 
   02 LINE 17 COLUMN 25 VALUE " Is this entry correct? (Y/N): ". 
   02 PIC X USING APPT-VERIFY AUTO. 
 
 
PROCEDURE DIVISION. 
P0. 
 
    DISPLAY MENU-SCREEN. 
 
*   The cursor position is not within an item on the screen, so the 
*   first item in the menu will be accepted first. 
 
    MOVE 0 TO CURSOR-LINE, CURSOR-COL. 
 
*   The user moves the cursor with the arrow keys to the 
*   desired menu item (to show, schedule, cancel, or print 
*   appointments) and selects the item by pressing <Return>. 
*   If the user wishes to exit without selecting an option, 
*   the user can press the F10 function key. 
 
    ACCEPT MENU-SCREEN. 
 
    IF KEY1 EQUAL "0" 
       PERFORM OPTION_CHOSEN 
 
    ELSE IF KEY1 EQUAL "1" AND FKEY-10 
       DISPLAY "You pressed the F10 key; exiting..." LINE 22. 
 
    STOP RUN. 
 
OPTION_CHOSEN. 
 
*   For brevity, the sample program includes complete code 
*   for the "Schedule Appointment" screen only.  A complete 
*   program for a calendar would also include code for 
*   displaying, canceling, and printing the day's appointments. 
 
    IF CURSOR-LINE = 7 
       DISPLAY "You selected Show Appointments" LINE 22. 
 
    IF CURSOR-LINE = 9 
       MOVE "01" TO APPT-DAY 
       MOVE "01" TO APPT-MONTH 
       MOVE "94" TO APPT-YEAR 
       MOVE "12" TO APPT-HOUR 
       MOVE "00" TO APPT-MINUTE 
       MOVE "AM" TO APPT-MERIDIEM 
       DISPLAY SCHEDULE-SCREEN 
 
*   The user types the description, date, and time of the 
*   appointment. 
 
       ACCEPT SCHEDULE-SCREEN 
 
       MOVE "Y" TO APPT-VERIFY 
       DISPLAY VERIFY-SUBSCREEN 
 
*   The user is asked, "Is this entry correct?"  Answer is 
*   Y or N. 
 
       ACCEPT VERIFY-SUBSCREEN. 
 
    IF CURSOR-LINE = 11 
       DISPLAY "You selected Cancel Appointments" LINE 22. 
 
    IF CURSOR-LINE = 13 
       DISPLAY "You selected Print Appointments" LINE 22. 
 
END PROGRAM MENU. 
In Figures 11_14 and 11-15, the output from the sample program is shown.

Figure 11-14 MENU-SCREEN Output (Alpha)



 
+------------------------------------------------------------------------------+ 
|                               Daily Calendar                                 | 
|                                                                              | 
|                                                                              | 
|                                                                              | 
|                                                                              | 
|                                                                              | 
|                           Show appointments for a day                        | 
|                                                                              | 
|                           Schedule an appointment                            | 
|                                                                              | 
|                           Cancel an appointment                              | 
|                                                                              | 
|                           Print your appointments                            | 
|                                                                              | 
|                                                                              | 
|                                                                              | 
|                                                                              | 
|                                                                              | 
|          Use the arrow keys to move the cursor among menu items.             | 
|          Press <Return> when the cursor is at the desired item.              | 
|          Press <F10> to exit.                                                | 
|                                                                              | 
|                                                                              | 
|                                                                              | 
|                                                                              | 
+------------------------------------------------------------------------------+ 
                                                                  

Figure 11-15 SCHEDULE-SCREEN Output (Alpha)



                                                                     
+------------------------------------------------------------------------------+ 
|                             Schedule Appointment                             | 
|                                                                              | 
|                                                                              | 
|                                                                              | 
| Description of Appointment:                                                  | 
|Meeting with Bill and Susan                                                   | 
|                                                                              | 
|                                                                              | 
| Date of Appointment (DD/MM/YY):   01/03/94                                   | 
|                                                                              | 
| Time of Appointment (HH:MM mm):   11:00 AM                                   | 
|                                                                              | 
|                                                                              | 
|                                                                              | 
|                                                                              | 
|                  Use Cursor Keys to move within the fields.                  | 
|                  Press <Tab> to enter next field.                            | 
|                  Press <Return> when finished.                               | 
|                                                                              | 
|                                                                              | 
|                                                                              | 
|                                                                              | 
|                                                                              | 
|                                                                              | 
+------------------------------------------------------------------------------+ 
 

Note

1 This does not include the VT100, VT200, VT300, VT400, and VT500 series terminals. On workstations that emulate these terminal types, this restriction may not apply.


Previous Next Contents Index