Overview of Character User Interface Methods | ![]() |
Server Express has many methods for creating user interfaces in both character and graphical environments. This chapter introduces the various methods available for creating user interfaces from your COBOL programs together with their advantages and disadvantages. A comparison table is provided at the end of the chapter for quick reference.
All the methods presented here are available on all environments supported by this and equivalent Micro Focus COBOL systems unless otherwise indicated.
The following screen handling methods are available:
Graphical:
Character:
Each of these methods is described briefly in the following sections.
Note: The user interface methods described are subject to the constraints of the UNIX operating system and hardware being used; in particular, attributes such as reverse-video and blink might not be available.
You can use Server Express to create HTML pages through which users can interact with COBOL applications. Extensions to the Micro Focus Object COBOL language enable you to access HTML pages in separate files - enabling you to use third party tools to create the HTML page - or to encode HTML in your COBOL program.
For details on how to create programs that use HTML pages to create GUIs through which you can access applications, see your Internet Applications book.
You can use third party tools to create your user interface, which you can then link to your COBOL program.
Dialog System enables you to remove all screen handling from an application and create character user interfaces. An application's human interface can subsequently be modified without the need to recompile the application. Dialog System also enables you to quickly specify and prototype a user interface without the need for a COBOL program. Using Dialog System's definition module you can interactively specify windows and objects and their associated dialog which are then stored in a screenset file on disk.
The dialog associated with each item in the user interface distinguishes Dialog System from other screen handling methods. The dialog consists of many useful screen handling and manipulation functions that can be associated with user events, such as pressing a key. For example, F1 could have dialog associated with it to go to another window, and this other panel could have dialog to go back to the initial window when the Escape key was pressed.
After the definition phase the Dialog System run-time module loads the screenset then displays windows and objects and executes dialog. Applications invoke Dialog System via a call interface using only two parameters - a control block and a data block. Comprehensive dialog functions are available in Dialog System together with many other features such as field validation and error message handling.
See your Dialog System Character Mode User's Guide for details.
Server Express provides syntax enabling you to draw lines and boxes on the screen, and create and remove rectangular areas on the screen which can be used as text virtual terminals. Such windows can be created as popups, and the underlying area restored when they are removed.
For details of the syntax, refer to the chapter Windowing Support for Text-based System.
$set preprocess(window1) working-storage section. 78 note-height value 16. 78 note-width value 41. 78 no-of-chars value note-height * note-width. 01 note-window pic x(10). 01 dummy pic x. 01 note-data value all "- wallpaper ". 03 note-char pic x occurs no-of-chars. screen section. 01 input-data highlight. 03 line 4 column 6 value " Accept and Display positions ". 03 line 5 column 6 value " are relative to the top left ". 03 line 6 column 6 value " corner of the window. ". 03 pic x using dummy. 01 note-screen pic x(no-of-chars) using note-data prompt " " reverse-video. procedure division. * Put a blank window on the screen with a border and title display window, line 2, column 38, lines note-height, size note-width, boxed, erase, reverse * Define a reference for this window so that * it can be removed and the previous display restored popup area is note-window bottom right title "Press Enter to remove window" * Fill the window with the contents of note-screen display note-screen display input-data accept input-data close window note-window.
Useful if you want a simple way of adding text windowing to a COBOL application.
The Screen Section is a section in the Data Division containing one or more screen definitions. A screen definition can contain fields, groups, text and attributes. Fields can have edited picture-strings and can also have such features as NO-ECHO, JUSTIFIED RIGHT and BLANK WHEN ZERO. The screen definitions are accepted and displayed in the Procedure Division.
working-storage section. 01 ws-customer-name pic x(20). 01 ws-customer-amount pic 99v9 value zero. screen section. 01 customer-screen. 03 blank screen. 03 line 1 column 33 value "Customer name". 03 line 1 column 47 pic x(20) using ws-customer-name prompt character is "*" justified right. 03 line 4 column 33 value "Customer amount". 03 line 4 column 49 pic z9.9 using ws-customer-amount required. procedure division. run-start. display customer-screen accept customer-screen stop run.
Useful if you want to have your screen definitions in a single place in the Data Division and want your applications to be X/Open compliant.
The enhanced ACCEPT/DISPLAY syntax enables screen position and screen attributes to be specified. You can do either single-field or multiple-field ACCEPT operations. For multiple-field ACCEPT operations, FILLER describes the number of character positions to skip over to the next field. In a DISPLAY operation, FILLER defines the number of spaces between display fields. All areas defined as FILLER are unaffected by the ACCEPT or DISPLAY operation.
The enhanced ACCEPT/DISPLAY and Screen Section ACCEPT/ DISPLAY operations use a run-time support module called Adis. Adis can be configured to an application's requirements using the configuration utility Adiscf. Calls can also be made from the COBOL application to Adis to configure it at run time; for example, to enable function keys.
working-storage section. 01 a-screen-text. 03 cust-name-text pic x(14) value "Customer name". 03 filler pic x(20). 03 cust-number-text pic x(16) value "Customer amount". 01 a-screen-data redefines a-screen-text. 03 filler pic x(14). 03 customer-name pic x(20). 03 filler pic x(16). 03 customer-amount pic z9.9. 01 ws-customer-amount pic 99v9. procedure division. run-start. move zero to customer-amount display a-screen-text at line 12 column 1 accept a-screen-data at line 12 column 1 move customer-amount to ws-customer-amount perform until ws-customer-amount not = zero display "Customer amount must not be zero" at line 25 column 1 with bell display customer-amount at line 12 column 51 with reverse-video blink accept a-screen-data at line 12 column 1 move customer-amount to ws-customer-amount end-perform stop run.
The ANSI ACCEPT syntax enables you to input a data item or accept the day, date or time into a data item. The ANSI DISPLAY syntax enables you to output literals and the contents of data items.
working-storage section. 01 a-field pic 9999. procedure division. run-start. accept a-field display "A-Field=" a-field stop run.
Only for elementary screen output and keyboard input.
The low-level interface is supplied by the COBOL system library routines. These routines enable you to access low-level functionality from a COBOL program. The example below shows only one method of putting text and attributes on the screen. Many other calls exist to access screen and keyboard functionality.
For details of these routines see the chapter Low-level Routines for Character Interfaces.
This example writes an 80-byte string of text and attributes to the screen. The text appears on the top line of the screen.
$set sourceformat(free) copy "cblproto.cpy". program-id. sample. working-storage section. 01 screen-position. 03 screen-row cblt-x1-compx value 20. 03 screen-col cblt-x1-compx value 0. 01 string-length cblt-x2-compx value 80. 01 attribute-buffer pic x(80). 01 character-buffer pic x(80). procedure division. move all "x" to character-buffer move all x"70" to attribute-buffer call "CBL_WRITE_SCR_CHATTRS" using screen-position character-buffer attribute-buffer string-length.
Useful if you specifically want to exploit the features of your machine and operating system, or if you require minimal memory overhead for your screen handling. Note that complicated screens might require many calls to these routines.
The table below provides a comparison between the screen handling methods:
Windowing | Compatible with other COBOL dialects? | Screen attributes | |
---|---|---|---|
Third-party tools | GUI | No | Yes |
HTML interface | GUI or text depending on browser | No | Yes |
Dialog System (character) | Text | No | Yes |
Windowing syntax | Text | No | Yes |
Screen Section | None | DG, X/Open RM and MS 2.2 | Yes |
Enhanced ACCEPT/DISPLAY | None | RM and MS 2.2 | Yes |
ANSI ACCEPT/DISPLAY | None | All | No |
Low-level (COBOL) | None | Limited1 | Yes |
Note:
1 Available in other Micro Focus COBOL systems, and in Microsoft COBOL 3.1 or later
Copyright © 2000 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.
Overview of Character User Interface Methods | ![]() |