|Overview of Character User Interface Methods|
Micro Focus COBOL 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 COBOL systems from Micro Focus unless otherwise indicated.
The following screen handling methods are available:
Graphical and Character:
Each of these methods is described briefly below. The graphical methods are described in detail in the part Graphical User Interfaces. The character methods are described in detail in the part Character User Interfaces.
See your Dialog System documentation for full details of Dialog System.
Dialog System, an add-on product from Micro Focus for use with this COBOL system, enables you to remove all screen handling from an application. 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 manipulating 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.
There are two versions available, one for creating graphical user interfaces and one for creating character user interfaces.
Only the version for creating character user interfaces is available on UNIX.
You can use third party tools to create your user interface, which you can then link to your COBOL program. For example, on the PC you can use Visual Basic or Powerbuilder.
DOS, Windows and OS/2:
On DOS, Windows and OS/2 a GUI Class Library is supplied with the COBOL system. This Class Library includes a large number of object classes that enable you to create windows, controls and message loops without the need to be familiar with the API of the underlying operating environment. Your application is portable across environments supported by the Micro Focus Object COBOL system.
For details of the public interfaces of the Class Library, see your OO Programming with Object COBOL.
DOS, Windows and OS/2:
On DOS, Windows and OS/2, Panels Version 2 is available as an API that enables you to create graphical user interfaces, but at a level which doesn't require use of the systems programming extension and the operating system API. Applications can be created to be generic across Presentation Manager, and Microsoft Windows V3.1 and later. It also offers an emulation mode of graphical objects on character displays on some environments.
This COBOL system enables you to use the application programming interfaces (APIs) offered with some operating systems to produce graphical user interfaces. For example, Presentation Manager on OS/2, and Microsoft Windows V3.1 and later.
This COBOL system 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 pop-up 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.
Panels provides comprehensive text windowing capabilities via a call interface. Any number of windows can be created and manipulated from a COBOL program, with up to 255 visible at a time. The visible part of a panel occupies a rectangular area on the screen which can be up to the physical size of the screen. A panel is a virtual rectangular area which can contain up to 65,536 characters. Comprehensive functions are available in Panels to manipulate a panel and its contents. For example: scrolling; block updates of characters and/or attributes; moving the panel on the physical screen; altering the size of the visible area. Output from Adis can be directed to a panel by making a call to Adis.
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.
A screen painting utility called Screens is included with this system. With Screens, you paint the required screen and Screens then generates the Screen Section code which can then be included in the application.
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 literals. 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.
working-storage section. 01 screen-position. 03 screen-row pic 9(2) comp-x value 0. 03 screen-col pic 9(2) comp-x value 0. 01 string-length pic 9(4) comp-x value 80. 01 character-buffer pic x(80). 01 attribute-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 overheads 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.
|Operating System Specific||Windowing||Compatible with other COBOL Dialects||Screen Attributes|
|Dialog System (graphical)||DOS
|Third Party Tools||All||GUI||No||Yes|
|GUI Class Library||DOS
|Dialog System (character)||No||Text||No||Yes|
|Screen Section||No||None1||DG, X/Open RM and MS 2.2||Yes|
|Enhanced ACCEPT/ DISPLAY||No||None1||RM and MS 2.2||Yes|
|ANSI ACCEPT/ DISPLAY||No||None||All||No|
1 This is possible via a call to Adis to direct input and output via Panels
2 Available in Microsoft COBOL 3.1 or later and other COBOL systems produced by Micro Focus
3 Attributes are specific to the environment
Copyright © 1999 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|