The DISPLAY Statement

The DISPLAY statement causes data to be transferred from specified data items to the appropriate hardware device, such as the CRT screen.

MFThe DISPLAY statement also transfers data from your program to the CRT or video terminal screen: non-scrolling forms, into which you can enter data, are displayed.

General Formats
Format 1
MFXOPENFormat 2
MFFormat 3
Syntax Rules
    Format 1
  1. The mnemonic-name must be associated with a function-name in the Special-Names paragraph in the Environment Division. See General Rule 9 in the topic The Special-Names Paragraph for a list of valid function-names.
  2. OSVSVSC2MFAlternatively, function-name can itself be used instead of an associated mnemonic-name.
  3. Each literal can be any figurative constant, except ALL.
  4. If the literal is numeric, it must be an unsigned integer.

    OSVSVSC2MFThis restriction can be ignored.

  5. MFXOPENWhen mnemonic-name is associated with ARGUMENT-NUMBER, then identifier-1 or literal-1 must each, if used, reference a data item defined as an unsigned integer or an unsigned integer literal respectively. Only a single identifier-1 or literal-1 can be used and the WITH NO ADVANCING phrase cannot be used.
  6. MFXOPEN When mnemonic-name is associated with ENVIRONMENT-NAME or ENVIRONMENT-VALUE, then identifier-1 or literal-1 must each, if used, reference an alphanumeric data item or a nonnumeric literal respectively. Only a single identifier-1 or literal-1 can be used and the WITH NO ADVANCING phrase cannot be used.
  7. The ON EXCEPTION and NOT ON EXCEPTION phrases can only be specified when mnemonic-name is associated with ENVIRONMENT-NAME or ENVIRONMENT-VALUE.
  8. MFXOPENFormat 2
  9. MFXOPENScreen-name cannot be an item with an OCCURS clause.
  10. MFFormat 2 and 3
  11. MFThe LINE and COLUMN phrases can appear in any order.
  12. MFInteger-3 and identifier-4 must be 4 or 6 digits long.
  13. MFFormat 3
  14. MFA DISPLAY statement with an operand that is not a screen-name is treated as a Format 3 DISPLAY statement if it has an AT phrase, an UPON phrase with the CRT or CRT-UNDER option, a WITH phrase, or a MODE IS BLOCK phrase; or if it has no UPON phrase but the CONSOLE IS CRT clause is specified in the Special-Names paragraph. If it has the UPON phrase with the CONSOLE option, or if it has no UPON phrase and the CONSOLE IS CRT clause is not specified in the Special-Names paragraph, it is treated as a Format 1 DISPLAY statement.
  15. MFThe phrases following the identifier can be in any order.
  16. MFElementary data items in identifier-1 must be of USAGE DISPLAY.
  17. MFNo elementary item in identifier-1 may be longer than 8191 bytes. If the MODE IS BLOCK phrase is used, the whole of identifier-1 must be no longer than 8191 bytes.
  18. MFIf a DISPLAY verb is followed by more than one identifier-1, any WITH clause applies only to the operand immediately preceding it.
  19. Format 4
  20. Different formats of the DISPLAY statement may be mixed together in one DISPLAY statement, as long as no ambiguity results. The effect is the same as specifying each DISPLAY statement separately.
  21. SCREEN LINE and SCREEN COLUMN NUMBER are numeric expressions or arithmetic expressions.
  22. Identifier-3 and literal-4 are screen locations specified as an integer data item or literal containing exactly 4 or 6 digits. It may also be a group item of 4 or 6 characters. If a numeric item is used, it must be a non-negative integer.
  23. LINE NUMBER, COLUMN NUMBER, SIZE (length), LINES (height) are numeric data items or literals. They may be non-integer values. You can also specify the value of any of these items with an arithmetic expression.
  24. FONT and CONTROL FONT are data items described as USAGE HANDLE or HANDLE OF FONT. They should contain valid handles to screen fonts.
  25. CELL SIZE, HEIGHT, WIDTH are positive integer data items or literals.
  26. Control-type-name is one of the control type reserved words known by the compiler.
  27. COLOR identifier-8 or literal-9 is a numeric data item or literal. COLOR can also be an arithmetic expression, except when used in the Screen Section.
  28. Identifiers 9-10 or literals 10-11 are integer literals or numeric data items. They may be arithmetic expressions. See section 6.4.9, "FOREGROUND-COLOR and BACKGROUND-COLOR Phrases," for a more detailed discussion of color settings and values.
  29. TITLE is an alphanumeric literal or data item.
  30. MINI-SIZE, MAX-SIZE, MIN-LINES, AND MAX-LINES are integer literals or data items.
  31. CONTROL VALUE is a numeric expression.
  32. The word "NO-CLOSE" is reserved by the compiler only when it appears in a Format 11 or 12 DISPLAY statement.
  33. Data-item 6 is a USAGE HANDLE or HANDLE OF LAYOUT-MANAGER that contains a valid reference to a layout manager.
  34. VISIBLE can also take a numeric literal or data item.
  35. POP-UP MENU is a USAGE HANDLE or HANDLE OF MENU data item.
  36. POP-UP AREA is a USAGE HANDLE, HANDLE OF WINDOW, or PIC X(10) data item.
  37. Proc-1 and proc-2 are procedure names.
  38. You must compile allowing for recursive paragraphs in order to specify the EVENT PROCEDURE phrase. Compiling for recursive paragraphs is allowed by default, but can be turned off with the "-Zr0" compiler option.
  39. The SCREEN LINE phrase and the SCREEN COLUMN phrase must be used together. If they are used, you cannot use the AT, LINE, or COLUMN phrases.
  40. If the COLOR phrase is specified, neither the FOREGROUND-COLOR nor the BACKGROUND-COLOR phrase may be specified.
  41. The POP-UP/HANDLE phrase may be specified anywhere in the statement after the required initial elements.
  42. IS and "=" are synonymous.
  43. COLUMN, COL, POSITION, and POS are equivalent.
  44. BLANK and ERASE are equivalent.
  45. HIGHLIGHT, HIGH, and BOLD are synonymous.
  46. LOWLIGHT and LOW are equivalent.
  47. REVERSE-VIDEO, REVERSE, and REVERSED are equivalent.
  48. COLOR and COLOUR are synonymous.
  49. FOREGROUND-COLOR and FOREGROUND-COLOUR are synonymous.
  50. BACKGROUND-COLOR and BACKGROUND-COLOUR are synonymous.
General Rules
    Format 1
  1. When operands in a DISPLAY statement have USAGE other than DISPLAY, or have included signs, they are converted to USAGE DISPLAY with separate sign. The size of the operand is taken as the size after conversion.
  2. If a figurative constant is specified as one of the operands, only a single occurrence of the figurative constant is displayed.
  3. MF If the function-name COMMAND-LINE, or a mnemonic-name associated with the function-name COMMAND LINE, is specified, data overwrites the contents of a system-dependent command-line buffer from where it can be retrieved by subsequent use of ACCEPT FROM COMMAND-LINE. Only one operand is allowed in this case.

    All permissible function-names other than those specifically mentioned in the general rules for Format 1 of the DISPLAY statement are treated as equivalent to CONSOLE and each operand is transferred to the console device in the order listed. The total size of data displayed is equal to the sum of the sizes of each operand. The display starts from the current cursor position, overflowing onto the following line(s) if necessary.

    On earlier releases, trailing spaces after the last operand were not displayed.

  4. ANS85If the NO ADVANCING phrase is specified, the cursor is then left at the space following the last character displayed; otherwise it is positioned at the start of the next line. Scrolling can take place whenever the cursor is moved to a new line.
  5. MFXOPENIf the mnemonic-name associated with the function-name ARGUMENT-NUMBER is used, then the position for any subsequent ACCEPT with a mnemonic associated with ARGUMENT-VALUE is set to retrieve the designated command-line argument. If the value associated with identifier-1 or literal-1 is less than 0, greater than 99, or greater than the total number of arguments on the command-line, then results are explicitly undefined.
  6. MFXOPENIf the mnemonic-name associated with the function-name ENVIRONMENT-NAME is used then the variable to be read or set in any subsequent ACCEPT or DISPLAY with a mnemonic associated with ENVIRONMENT-VALUE is set to the designated variable-name specified in literal-1 or as the contents of identifier-1. The ON EXCEPTION phrase is ignored. If any problem occurs while trying to set an ENVIRONMENT-NAME for a subsequent ACCEPT or DISPLAY associated with ENVIRONMENT-VALUE, then it is only the subsequent ACCEPT or DISPLAY that must detect the ON EXCEPTION condition.
  7. MFXOPENIf the mnemonic-name associated with the function-name ENVIRONMENT-VALUE is used then
    1. If a previous DISPLAY with a mnemonic-name associated with an ENVIRONMENT-NAME has been done, then the value of the identifier is placed into the designated environment variable.
    2. If no previous DISPLAY with a mnemonic-name associated with an ENVIRONMENT-NAME has been performed, or, for ACCEPT, if the specified environment variable does not exist, or, for DISPLAY, not enough space can be allocated to store the environment variable, the imperative statement associated with an ON EXCEPTION phrase is executed. The value in identifier is undefined in this case.
  8. MFXOPENIf the mnemonic-name associated with the function-name SYSERR is used, then a DISPLAY is performed as if to the CONSOLE except that all output is directed to the system's standard Error Device.
  9. MFXOPENWhen using DISPLAY UPON ENVIRONMENT-VALUE, trailing spaces are included in the value. You should use INSPECT REPLACING ALL SPACE BY LOW-VALUES to avoid this.
  10. OSVSVSC2MFWithin identifier-1, internal floating-point numbers are converted to external floating-point numbers for display, so that:
    1. A COMP-1 item is displayed as if it has an external floating-point PICTURE clause of -.9(8)E-99.
    2. A COMP-2 item is displayed as if it has an external floating-point PICTURE clause of -.9(18)E-99 (even though this picture string is illegal if explicitly specified).
  11. OSVSVSC2MFLiteral-1 may be a floating-point literal.
  12. MFXOPENFormat 2
  13. MFXOPENThis format of the DISPLAY statement displays screen items, which are defined in the Screen Section of the program, and allows full access to the enhanced screen handling facilities.
  14. MFFormat 2 and 3
  15. MFThe AT phrase gives the absolute address on the screen where the DISPLAY operation is to start.
  16. MFThe order of execution of a DISPLAY statement is always:
    1. The AT phrase
    2. The BLANK phrase
    3. The BELL phrase
    4. The DISPLAY operation
  17. MFIf integer-3 or identifier-4 is 4 digits long, the first two digits specify the line, the second two the column. If 6 digits long, the first three digits specify the line, while the second three specify the column.
  18. MFCertain combinations of line and column numbers have special meanings, as follows:
    1. Until the column comes within range, out of range column values are reduced by the line length and the line value is incremented.
    2. Out of range line values cause the screen to scroll up one line. The effect is the same as if the line number of the bottom line had been specified.
    3. If the line and column numbers given are both zero, the DISPLAY starts at the position following that where the preceding Format 2 or Format 3 DISPLAY operation finished. Column 1 of each line is considered to follow the last column of the previous line.
    4. If the line number is zero, but a non-zero column number is specified, the DISPLAY starts at the specified column, on the line following that where the preceding Format 2 or 3 DISPLAY operation finished.
    5. If the column number is zero, but a non-zero line number is specified, the DISPLAY starts on the specified line, at the column following that where the preceding Format 2 or 3 DISPLAY operation finished.
  19. MFFormat 3
  20. MFPart of this statement can be repeated to allow the display of several data items. If the first item has no AT phrase, it begins at line 1, column 1. Each subsequent item begins at the current cursor position as left after the previous item.
  21. MFIf identifier-1 is a group item and no MODE IS BLOCK phrase exists, those elementary subordinate items which have names other than FILLER are displayed. They are displayed simultaneously, positioned on the screen in the order their descriptions appear in the Data Division, and separated by the lengths of the FILLER items in the group. For this purpose, the first position on a line is regarded as immediately following the last position on the previous line.
  22. MFThe MODE IS BLOCK phrase indicates that the identifier is to be treated as an elementary item. Thus, even if it is a group item it is displayed as one item.
  23. MF The WITH phrase allows you to specify certain options available during the operation. (See the chapter Screen Section Entry Skeleton for descriptions of these options.)

    In addition to the options available as screen description clauses, the following options can be used in the WITH phrase; SPACE-FILL, ZERO-FILL, LEFT-JUSTIFY, RIGHT-JUSTIFY, TRAILING-SIGN and UPDATE. ZERO-FILL appears in this list and as a screen description clause because it has two different uses. Its second use is documented later in this chapter.

    A configuration option is available which allows the entry of data into numeric and numeric edited screen fields in free format mode. In COBOL, nonedited numeric data items are intended for holding data in an internal form; however, this format enables such data items to appear on the screen. See your COBOL system documentation on user interfaces for more details. If free format mode is in effect, the data appears automatically reformatted as follows:

    The SPACE-FILL, ZERO-FILL, LEFT-JUSTIFY, RIGHT-JUSTIFY and TRAILING-SIGN options amend this format.

  24. MFIf the literal-1 is one of the following figurative constants it has a special effect as follows: SPACE clears from the specified cursor position to the end of the screen; LOW-VALUE moves the cursor to the specified position; ALL X"01" clears from the specified cursor position to the end of the line; ALL X"02" clears the whole screen; ALL X"07" sounds the bell. If the literal is a figurative constant that is not listed above and the SIZE option is not specified, one occurrence of its value is displayed.
  25. MF If the SIZE option is specified for a figurative constant that has no special effect, then that figurative constant is displayed as many times as necessary to reach the length specified in the SIZE option. However, if the display wraps around to a new line, it starts again at the beginning of the figurative constant.
  26. MF If the FOREGROUND-COLOR option is specified, then the specified color becomes the default foreground color if and only if the entire screen is cleared by this display. The entire screen is cleared either when the BLANK SCREEN option is specified or when literal-1 is SPACES and the DISPLAY starts at line 1 column 1.
  27. MF If the BACKGROUND-COLOR option is specified, then the specified color becomes the default background color if and only if the entire screen is cleared by this display.
  28. MFIf REDEFINES is used within identifier-1, the first description of the redefined data area is used and subsequent descriptions are ignored. If OCCURS or nested OCCURS are used the repeated data item is expanded into the full number of times it occurs, so that one definition is repeated for many fields.
  29. Format 4
  30. The DISPLAY INITIAL WINDOW verb creates the main application window. The main application window has several special properties. If it is minimized, all other windows in the application are also minimized. If it is closed, the application terminates. A program can have only one main application window.
  31. If you attempt to create a main application window after one already exists, the DISPLAY INITIAL WINDOW statement will have no effect other than to set handle-name to NULL.
  32. The runtime automatically constructs the main application window if needed. This occurs any time a screen operation is dictated by the program and the program has not yet constructed a main application window. When this occurs, the runtime executes the following implied statement:
    DISPLAY INITIAL WINDOW
        TITLE-BAR,
        SYSTEM MENU,
        AUTO-MINIMIZE,
        AUTO-RESIZE.
  33. The main application window is always modeless. A modeless window is one where the user can switch to another window while the current window is still open. You can include the word MODELESS in the statement as commentary.
  34. The INDEPENDENT phrase creates an independent window. Independent windows act like additional main application windows. Independent windows have the following traits:
    1. Independent windows do not have a parent. As a result, any other window in the application can be placed over them. Also, destroying another window in the application will not destroy the independent window.
    2. Although they do not have a parent, independent windows use the current window to determine their default fonts, cell size, and colors. Also, independent windows use the current window when determining their position. This is computed in the same manner as it is for floating windows.
    3. Independent windows can be minimized separately. Under Windows, each visible independent window has its own button on the task bar.
    4. Independent windows process their close box in the same manner as floating windows--by generating a CMD-CLOSE event.
    5. Independent windows can be created before the main window. In this case, there is no current window to provide defaults, so the independent window uses the same defaults as the main application window would. The window is located on the screen as follows:

      According to SCREEN LINE and SCREEN COL, if specified; otherwise

      If the window has a title bar, the host system places the window as if it were a new application; otherwise

      The window is centered in the screen.

      Note that LINE and COL (without the SCREEN option) are ignored in these cases.

    6. If an independent window is current when the main application window is created, the defaults for the main window are derived from the independent window.
  35. Most of the phrases allowed for DISPLAY INITIAL WINDOW work in exactly the same way that they work in a DISPLAY FLOATING WINDOW (format 11) statement. The following rules are supplemental.
  36. The SCREEN-LINE and SCREEN-COLUMN Phrases. Under Windows, the runtime ensures that the initial window is fully visible, so the location specified by screen-line and screen-col may not be used if that would place a portion of the window off the screen (the closest allowed location is used).
  37. The TITLE-BAR Phrase. If you specify a TITLE-BAR but do not give a TITLE, the default title is the name of the program (PROGRAM-ID in the IDENTIFICATION DIVISION).
  38. The AUTO-MINIMIZE Phrase. The AUTO-MINIMIZE phrase indicates that a minimize button should be displayed. The runtime handles the minimizing and restoring of the application automatically. If you do not specify AUTO-MINIMIZE, the user is not allowed to minimize the application. In addition, the AUTO-MINIMIZE phrase implies the SYSTEM MENU and TITLE-BAR phrases.
  39. The Window Location and Size.
    1. The window's location on the screen is determined by the host system, as are its initial dimensions if it is resizable. You can use the SCREEN runtime configuration variable to specify the initial window dimensions (including whether it is maximized or minimized).

      On a character-based system, the initial window always occupies the entire terminal surface. Setting the various sizing options has no effect.

    2. If you do not use the LINES and SIZE phrases, the lines and size values are taken from the SIZE option of the SCREEN runtime configuration variable. If SCREEN is not set, the default size is 25 lines by 80 columns. The host system may provide a smaller default (for example, 24line character-based terminals will default to 24 lines).
  40. The STANDARD Phrase. The STANDARD option is identical to the INITIAL option except that it automatically implies the following options:
    1. TITLE-BAR
    2. SYSTEM MENU
    3. AUTO-MINIMIZE
    4. USER-COLORS
    5. For graphical systems, a black foreground on a white background. For character-based systems, a white foreground on a black background. You may override these default colors with the various color setting phrases.
  41. The GRAPHICAL phrase has the same effect as in the DISPLAY FLOATING WINDOW statement.
  42. The VISIBLE option determines whether the window created is visible or invisible. If the FALSE option is used, or if it is set to the value zero, then the window is invisible. Otherwise, the window is visible. If the VISIBLE phrase is omitted, then the window is visible.
  43. The POP-UP MENU phrase associates a pop-up menu with the window. If data-item-8 is specified, then the menu associated with data-item-8 becomes the pop-up menu. If NULL is specified, the window is not given a pop-up menu. Pop-up menus are activated by a machine-dependent technique. Under Windows, the technique is to right-click on the window's background.
  44. The CONTROLS-UNCROPPED Phrase.

    Normally, when you create a control in a window, the control is cropped to fit the current subwindow's dimensions. In addition, if the control's home position is outside of the current subwindow, the control is not created. Adding the phrase CONTROLS-UNCROPPED overrides these rules. When this phrase is used, the control is created with the specified location and dimensions, regardless of whether the control will be physically in the window.

    This can be useful when you are dealing with RESIZABLE windows. Sometimes a resizable window is too small to show all of the controls that your program creates. Normally, these controls either would not be created or would be cropped. This could produce odd results when the window is later resized larger by the user. Although the resized window is now large enough to show everything, the controls still show their cropped appearance, because their (cropped) creation size is recorded in the controls as their actual size. Specifying CONTROLS-UNCROPPED avoids the cropping behavior.

    This style is useful also when you want to place a combo-box near the bottom of a window. Because the size of the drop-down portion of the combo-box is determined by the control's overall height, cropping the control limits the drop-down box to the window's boundaries. If you want the box to drop down beyond the edge of the window, you need to use the CONTROLS-UNCROPPED window style to allow this.

  45. The EVENT PROCEDURE Phrase. A window's event procedure is executed whenever an event is processed for that window. The event procedure is executed as if it were the target of a PERFORM statement. Only the window's own events trigger the event procedure. Events generated by controls contained in the window do not trigger the window's event procedure (they trigger the control's event procedure instead). The event procedure executes while the event is being processed, before the event causes termination of any executing ACCEPT statement. See section 5.9.6, "PROCEDURE Clause," for more information about event procedures.

    Specifying proc-1 assigns that procedure as the window's event procedure. Flow of control returns at the end of proc-1, unless proc-2 is specified, in which case flow of control returns at the end of proc-2. If you specify the NULL option, the window does not have an event procedure. This is the default, so the NULL option is treated as commentary.

    Note: The Support area of the extend Web site includes a sample program that demonstrates how a main application window can be coded to detect the system display's screen resolution and then size itself to fill the entire screen. To download the program, go to: www.acucorp.com/support/public/sample_programs/index.php. Select the category "Graphical User Interface Sample Programs" from the drop down list, and click on "WIN-START-MAX.cbl".