[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
User Manual


Previous Contents Index

11.3.1.1 Comparison of Screen Section Extensions (Alpha, I64) 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:

  • You can clear part or all of your screen as you DISPLAY a screen. Each output screen item within a screen description entry can specify an ERASE option.
  • With all formats, if you do not specify the initial cursor position, by default it will be at the upper left corner of the screen --- screen coordinates (1,1), first line, first column.
  • Each screen item within a screen description entry can specify a line and column position. If the line and column are not specified for a screen item, then the screen item begins immediately following the previous screen item.
    Regardless of whether you display or accept the entire screen or only part of the screen, the positioning of each screen item remains the same.
  • If you display escape or control sequences within a screen description entry, you need to use absolute cursor positioning to get predictable results.

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, I64) and the non-Screen Section screen formats. With the Screen Section:

  • You can define screen items that wrap onto multiple lines. The editing of these fields during an ACCEPT operation differs from that of the other extended formats of ACCEPT.
  • The use of editing keys during an ACCEPT is always allowed.
  • The size of each field (for an elementary screen item) is defined by the PICTURE or VALUE clause.
  • Conversion is always performed during an ACCEPT; as the operator leaves each field, HP COBOL performs field validation and conversion and displays the resulting value.
  • The screen does not scroll during a Screen Section ACCEPT or DISPLAY. Any fields that are positioned beyond the edge of the screen are truncated.
  • In addition to the line and column position for each screen item, you can also specify a line and column position for the ACCEPT and DISPLAY statements. By default, this position is at (1,1), so your screen item positions are offset from the upper left corner of the screen. However, if you specify new starting screen coordinates with the LINE and COLUMN options of the ACCEPT or DISPLAY statement, you thereby resize the screen. Then any LINE and COLUMN options specified in the screen description entry are positioned for the resized screen coordinates.
    For example, if you picture the usual terminal screen as follows:


        +---------------+
        |               |
        |               |
        |               |
        |               |
        |               |
        +---------------+
    
    the LINE and COLUMN values specified in the ACCEPT or DISPLAY statement might resize the screen as shown in the following interior box:


        +---------------+
        |               |
        |   +-----------+
        |   |           |
        |   |           |
        |   |           |
        +---+-----------+
    

    It can be useful to specify LINE and COLUMN in both your screen description entry and in your ACCEPT or DISPLAY statement. For example, in your screen description entry, you could create a legend box, and then specify with the DISPLAY statement's LINE and COLUMN options the starting screen coordinates of (1,60) to display the legend in the upper right corner of the screen (starting in the 60th column of the first line). Elsewhere, you could display the legend box, using the same screen description entry, at a different position on the screen, by choosing different LINE and COLUMN options with the DISPLAY statement.
  • The default value for an update screen item is the current value of the FROM or USING data item. The default value for an input screen item is spaces or zero, depending on the data type of the screen item.
    If the operator terminates the ACCEPT before entering a value for each field, the default value remains in the untouched screen items.
  • To catch any function keys that the operator presses, use the CRT STATUS option. All control sequences are captured and processed by HP COBOL and not returned to the application.

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

In Example 11-12 (Alpha and I64 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, I64)

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.


Previous Next Contents Index