Screen Handling Methods [ Micro Focus COBOL for UNIX COBOL User Guide ] MPE/iX 5.0 Documentation
Micro Focus COBOL for UNIX COBOL User Guide
Screen Handling Methods
The following screen handling methods are available in this product:
* ANSI ACCEPT/DISPLAY
* Enhanced ACCEPT/DISPLAY
* Screen Section
* COBOL Windowing Syntax (UNIX only)
* Low level - COBOL System Library Routines
* Low level - graphical user interface API
* Panels
In addition, the following methods are available in add-on products from
Micro Focus:
* Panels Version 2
* Dialog System
Each of these methods is described briefly below. For full details of
the methods available in this product see your Language Reference and
COBOL System Reference.
ANSI ACCEPT/DISPLAY
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.
Example.
working-storage section.
01 a-field pic 9999.
procedure division.
run-start.
accept a-field
display "A-Field=" a-field
stop run.
Advantages.
* Portable across all COBOL dialects
* No overhead of the ACCEPT/DISPLAY module, Adis
Disadvantages.
* No positional information can be specified
* No attributes can be specified
* Field type on an ACCEPT operation is treated as alphanumeric - any
characters can be entered into a field even if it is defined as
numeric
* Only a single field can be input by one ACCEPT statement
Comment.
Only for elementary screen output and keyboard input.
Enhanced ACCEPT/DISPLAY
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.
Example.
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.
Advantages.
* Can specify position of ACCEPT/DISPLAY operation
* Can accept/display one or more fields
* Can specify attributes for ACCEPT/DISPLAY operation
* Formatting of numeric fields during input
* RM compatible (using RM directive)
* MS 2.2 compatible (using MS"2" directive)
* X/Open Compatible
Disadvantages.
* Not portable across all COBOL dialects
* Can take up large amounts of memory loading Adis
* FILLER items used when accepting more than one field waste space
Screen Section
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 product.
With Screens, you paint the required screen and Screens then generates
the Screen Section code which can then be included in the application.
Example.
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.
Advantages.
* Only writes to the specified areas of the screen, leaving other
areas unaffected
* Can specify position of screen and its text and data
* Can accept/display one or more fields and groups
* Can specify attributes for ACCEPT/DISPLAY operation
* Can specify field input acceptance order
* More readable presentation of the screen's layout because all
information relevant to a particular screen is in one place and
the syntax is easily understood
* Only the parts of the screen specifically defined are stored (as
opposed to the enhanced ACCEPT/DISPLAY method which can involve
using FILLER items which take up memory)
* DG compatible (using DG directive)
* MS 2.2 compatible (using MS"2" directive)
* X/Open Compatible
Disadvantages.
* Not portable across all COBOL dialects
* Marginally slower than the multiple-field ACCEPT described in the
previous section if a screen contains a lot of text and data
* Memory overhead of Adis
Comment.
Useful if you wish to have your screen definitions in a single place in
the Data Division and want your applications to be X/Open compliant.
Windowing Syntax
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 virtual terminals. Such windows can be created as
pop-ups, and the underlying area restored when they are removed.
Windowing syntax is supported on DOS, Windows, OS/2 and UNIX.
For details of the syntax, refer to your COBOL System Reference and your
Language Reference.
Example.
$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.
Advantages.
* Adds windowing to COBOL
* Requires no additional software
* Makes it easy to draw forms on the screen
Disadvantages.
* Not portable across all COBOL dialects
* Cannot be used with calls to Panels in the same run unit
Comment.
Useful if you want a simple way of adding windowing to a COBOL
application.
Low Level-COBOL System Library Routines
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 your COBOL System Reference.
Example.
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
Advantages.
* Fast - operating system level interface
* No overhead of Adis module
Disadvantages.
* Can require many calls to build up a complete screen.
* Parameters can be complicated. For example, offsets might need to
be calculated.
Comment.
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.
Low Level-Graphical User Interface API
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,
Microsoft Windows 3.0 and later and Motif.
Advantages.
* Graphical user interfaces can be created
* Makes available the full power of the operating system API
Disadvantages.
* Not portable across all COBOL dialects
* Complicated programming style, not familiar to most COBOL
programmers
Panels
Panels provides comprehensive 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.
Advantages.
* Provides windowing
* Ability to scroll (left, right, up, down) a specified rectangle of
text and attributes inside a panel
* Panels can be moved
* The visible area of the panel can be altered
* Can ACCEPT/DISPLAY through Panels
Disadvantages.
* Can use up a lot of memory if many large panels are created
* Accept/display via
Panels is a bit slower than using ACCEPT/DISPLAY operations direct
to the
screen
* Memory overhead of Panels
* Memory overhead of Adis (if used)
Panels Version 2
Panels V2 is available in a Micro Focus add-on product for use with this
COBOL system. It is 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, Microsoft Windows 3.0
and later and Motif
. It also offers an emulation mode of graphical objects on character
displays on some environments.
Advantages.
* Used to create graphical user interfaces
* Portable (across environments where Panels V2 is available)
* No need to learn complicated programming style
Disadvantages.
* High memory usage
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.
Advantages.
* Separates the human interface logic out of the application,
thereby enabling panels to be modified without recompiling the
application
* Separates the user interface software from the application,
allowing the user interface to run via a network on a different
machine to the application
* Enables rapid prototyping of human interfaces - using the run
option in the definition software you can try out your panels
without needing a program
* Provides field validation and the ability to associate error
messages with validation
* Used to create graphical user interfaces
* Portable (across environments where Dialog System is available)
* Simple to call, well defined interface
* Print screensets - for reference or documentation purposes
* Screen definitions stored in a very compressed form saving disk
space and memory
Disadvantages.
* Run-time support larger than for other
screen handling methods
MPE/iX 5.0 Documentation