Screen Handling Methods [ COBOL/HP-UX Operating Guide for the Series 700 and 800 ] MPE/iX 5.0 Documentation
COBOL/HP-UX Operating Guide for the Series 700 and 800
Screen Handling Methods
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 its configuration utilities ADISCF and KEYBCF. Calls
can also be made from the COBOL application to ADIS to configure it at
run time; for example, to enable function keys.
ANSI ACCEPT/DISPLAY
The ANSI ACCEPT syntax enables users to input a data-item or accept the
day, date or time into a data-item. The ANSI DISPLAY syntax enables
users 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 ANSI-conforming dialects
* No overhead of the ACCEPT/DISPLAY module, ADIS
Disadvantages
* No positional information can be specified
* No attributes can be specified
* Field type on ACCEPT 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. Users 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.
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 aiding portability between X/Open compliant COBOL
dialects.
Disadvantages
* Not portable across all COBOL dialects
* Can take up large amounts of memory if accepting more than one
field due to FILLERs being required.
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.
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)
Disadvantages
* Marginally slower than the multiple-field ACCEPT described in the
previous section if a screen contains a lot of text and data.
Comment
For users who wish to have their screen definitions in a single place in
the Data Division and want their applications to be X/Open compliant.
Windowing Syntax
This COBOL system provides syntax allowing 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.
For details of the syntax, refer to Chapter 26 , Windowing Support 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 guaranteed to be source code compatible
* Not portable to dialects of COBOL
* Color is not supported within ACCEPT/DISPLAY statements
* Cannot be used with calls to Panels in the same run-unit
Comment
For users who require 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 users 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 Chapter 8 , Library Routines (Call-
by-Name).
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
* Environment specific; for example, attribute formats can differ
between environments
* Can require many calls to build up a complete screen
* Can cause machine to hang if used incorrectly; for example, if
incorrect parameters are specified
*
Low level; parameters can be complicated and require calculation.
For example, offsets may need to be calculated
* Growth path is not guaranteed - moving to a different machine or
new operating system may require recoding parts of the application
Comment
For users who specifically want to exploit the features of a
machine/operating system, or for users who require minimal memory
overheads for their screen handling. Note that complicated screens may
require many calls to these routines.
Panels
Panels provides applications with comprehensive windowing capabilities
via a call interface. Any number of windows can be dynamically 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 64K 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 (see the chapter ADIS).
Advantages
* Provides windowing capabilities
* 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 a lot of memory if many large panels are created
* ACCEPT/DISPLAY via
Panels is a bit slower than using ACCEPT/DISPLAY direct to the
screen
Dialog System
Dialog System is a Micro Focus add-on product for use with this COBOL
system. It allows
screen handling related code to be completely separate from the rest of
an application. An application's human interface can, therefore, be
modified without the need to recompile the application. Dialog System
also enables users to specify and prototype panels quickly without the
need for a COBOL program. Using Dialog System's definition module the
user can interactively specify panels and their associated "dialog" which
are then stored in a screenset file on disk.
The dialog associated with a panel distinguishes Dialog System from other
screen handling products. The dialog consists of many useful screen
handling and manipulating functions which can be associated with an
event. For example, F1 could have dialog associated with it to go to
another panel, and this other panel could have dialog to go back to the
initial panel when the Escape key was pressed.
After the definition phase, the Dialog System run-time module loads the
screenset, then displays panels 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 with many other features such as field validation and error
message handling.
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, in character or graphical (GUI) mode
* Enables rapid prototyping of human interfaces - using the run
option in the definition software users can try out their panels
without needing a program
* Provides field validation and the ability to associate error
messages with validation
* Portable
* Simple to call, well defined interface
* Ability to print screensets - for reference or documentation
purposes
* Screen definitions stored in a very compressed form saving disk
space and memory
Disadvantages
* Significant learning curve
* Run-time support larger than for other
screen handling methods
MPE/iX 5.0 Documentation