Compaq COBOL
User Manual


Previous Contents Index

11.2.7 Using the EDITING Phrase

Specifying the EDITING phrase of the ACCEPT statement enables field editing. Table 11-3 briefly describes the keys that the EDITING phrase enables. See the ACCEPT section of Compaq COBOL Reference Manual for a complete list of field editing keys.

Table 11-3 Key Functions for the EDITING Phrase
Key Function Description
Left arrow Move-left Moves the cursor one space to the left. If the cursor is at the first character position of the field, the terminal bell rings.
Right arrow Move-right Moves the cursor one space to the right. If the cursor is one space beyond the rightmost character position of the field, the terminal bell rings.
F12 (BS) Beginning-of-field Positions the cursor to the first character position of the field.
Ctrl/E End-of-field Moves the cursor one position beyond the rightmost character position in the field.
Ctrl/U Erase-field Erases the entire field and moves the cursor to the first character position of the field.
F14 Switch-mode Switches the editing mode between insert and overstrike.

Example 11-11 shows the sample code that produces the form in Figure 11-13. (The Current Value field is provided for example purposes only.)

Example 11-11 EDITING Phrase Sample Code

   . 
   . 
   . 
PROCEDURE DIVISION. 
A1000-BEGIN. 
    OPEN I-O EMP-FILE. 
   . 
   . 
   . 
B1000-MODIFY. 
    DISPLAY "MODIFY EMPLOYEE INFORMATION FORM"  ERASE SCREEN   
                                        AT LINE 2       COLUMN 8. 
    DISPLAY "Enter Employee Number : "  AT LINE PLUS 2  COLUMN 8. 
 
    ACCEPT EMP-KEY 
        FROM LINE 4 COLUMN 32 
        PROTECTED WITH EDITING REVERSED 
        DEFAULT IS CURRENT 
        AT END 
          STOP RUN. 
   . 
   . 
   . 
B2000-DISPLAY. 
 
    MOVE EMP-REC TO OUT-REC. 
 
    DISPLAY "Date of Hire : "           AT LINE PLUS 2  COLUMN 8. 
    DISPLAY MON-IN                      AT              COLUMN 24. 
    DISPLAY "-"                         AT              COLUMN 26. 
    DISPLAY DAY-IN                      AT              COLUMN 27. 
    DISPLAY "-"                         AT              COLUMN 29. 
    DISPLAY YR-IN                       AT              COLUMN 30. 
    DISPLAY "Current Value :"           AT COLUMN 38. 
    DISPLAY MON-NUM                     AT              COLUMN 54. 
    DISPLAY "-"                         AT              COLUMN 56. 
    DISPLAY DAY-NUM                     AT              COLUMN 57. 
    DISPLAY "-"                         AT              COLUMN 59. 
    DISPLAY YR-NUM                      AT              COLUMN 60. 
 
    DISPLAY "Department :"              AT LINE PLUS 2  COLUMN 8. 
    DISPLAY DEPT-IN                     AT              COLUMN 21. 
    DISPLAY "Current Value :"  AT  COLUMN 38. 
    DISPLAY DEPT-NUM                    AT              COLUMN PLUS. 
    
 
    DISPLAY "First Name :"              AT LINE PLUS 2  COLUMN 8. 
    DISPLAY F-NAME-IN                   AT              COLUMN 21. 
    DISPLAY "Current Value :"  AT              COLUMN 38. 
    DISPLAY F-NAME                      AT              COLUMN PLUS. 
 
    DISPLAY "Last Name :"               AT LINE PLUS 2  COLUMN 8. 
    DISPLAY L-NAME-IN                   AT              COLUMN 20. 
    DISPLAY "Current Value :"  AT              COLUMN 38. 
    DISPLAY L-NAME                      AT              COLUMN PLUS. 
 
    ACCEPT MON-NUM 
        FROM LINE 6 COLUMN 24 
        PROTECTED WITH EDITING REVERSED 
        DEFAULT IS CURRENT 
        AT END 
          STOP RUN. 
 
    DISPLAY MON-NUM                    AT LINE 6       COLUMN 54. 
 
    ACCEPT DAY-NUM 
        FROM LINE 6 COLUMN 27 
        PROTECTED WITH EDITING REVERSED 
        DEFAULT IS CURRENT 
        AT END 
          STOP RUN. 
 
    DISPLAY DAY-NUM                    AT LINE 6       COLUMN 57. 
 
    ACCEPT YR-NUM 
        FROM LINE 6 COLUMN 30 
        PROTECTED WITH EDITING REVERSED 
        DEFAULT IS CURRENT 
        AT END 
          STOP RUN. 
 
    DISPLAY YR-NUM                     AT LINE 6       COLUMN 60. 
 
    ACCEPT DEPT-NUM 
        FROM LINE 8 COLUMN 21 
        PROTECTED WITH EDITING REVERSED 
        DEFAULT IS CURRENT 
        AT END 
          STOP RUN. 
 
    DISPLAY DEPT-NUM                   AT LINE 8       COLUMN 54. 
 
    ACCEPT F-NAME 
        FROM LINE 10 COLUMN 21 
        PROTECTED WITH EDITING REVERSED 
        DEFAULT IS CURRENT 
        AT END 
 
          STOP RUN. 
 
    DISPLAY F-NAME                     AT LINE 10      COLUMN 54. 
 
    ACCEPT L-NAME 
        FROM LINE 12 COLUMN 20 
        PROTECTED WITH EDITING REVERSED 
        DEFAULT IS CURRENT 
        AT END 
          STOP RUN. 
 
    DISPLAY L-NAME                     AT LINE 12      COLUMN 54. 
   . 
   . 
   . 

Figure 11-13 Form with ACCEPT WITH EDITING Phrase


Because the ACCEPT statements in Example 11-11 contain EDITING phrases, a person using the form in Figure 11-13 can use any of the keys listed in Table 11-3 for field editing purposes to make corrections or modifications.

11.3 Designing Video Forms with Screen Section ACCEPT and DISPLAY

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

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
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 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 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, 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

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



 
+------------------------------------------------------------------------------+ 
|                               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


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