Operation [ 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
Operation
In order to use the windowing syntax, you must use the PREPROCESS"WINDOW1"
compiler directive either:
* in the source file as:
$SET preprocess"window1"
Note that window1 must be lower case.
or
* from the command line:
cob -C preprocess=window1 prog.cbl
(This directive must be the last compiler directive apart from NOERRQ.
When an error is encountered, the compiler will ask if you wish to
continue, and waits for your response. In order to disable this
function, you must specify the NOERRQ directive after PREPROCESS
"WINDOW1".)
The CLOSE WINDOW Statement
The CLOSE WINDOW statement closes the current video terminal window.
Format
CLOSE WINDOW window-save-area
Syntax Rule
Window-save-area must be an elementary data item described by a PICTURE
X(10) clause. It must have been the object of a POP-UP AREA phrase in a
DISPLAY WINDOW statement.
General Rules
1. The CLOSE WINDOW statement is used to remove "pop-up" windows
created by the POP-UP AREA option of the DISPLAY WINDOW statement.
2. Window-save-area must have been the object of a POP-UP phrase of a
DISPLAY WINDOW statement that has been executed in this run-unit.
Furthermore, since that execution, it must not have been the
object of a CLOSE WINDOW statement nor may it have been modified
by any other statement. Violation of these rules causes undefined
results.
3. The CLOSE WINDOW statement restores the contents of the terminal
screen that was in the active window when the corresponding
DISPLAY WINDOW statement executed. In other words, the window
that was created by that DISPLAY WINDOW statement is removed from
the screen and replaced by the contents of the screen which were
"under" that pop-up window.
4. The window that was active when the corresponding DISPLAY WINDOW
statement executed becomes the active window, thereby becoming the
top window and overlaying any other windows that might be present.
The current window is selected by closing windows identified by their
respective window-save-areas, as in the following example:
If five pop-up windows are created, a, b, c, d and e in that order:
* when d is closed, c becomes current
* if b is then closed, a becomes current
* if e is subsequently closed, c becomes current again.
The DISPLAY Statement
This chapter explains COBOL Windowing, which gives you three additional
formats for creating windows and drawing lines and boxes. Other formats
(which are also applicable to ANSI and Screen Section types) are
described in your Language Reference .
Format 1
Figure 26-1.
Format 2
Figure 26-2.
Format 3
Figure 26-3.
Syntax Rules
1. line-num is a numeric literal or data item that specifies the line
position on the terminal screen. It must be a nonnegative
integer.
2. col-num is a numeric literal or data item that specifies the
column position on the terminal screen. It must be a nonnegative
integer.
3. length is a numeric literal or data item that specifies the
window-width in character positions. It must be a nonnegative
integer.
4. height is a numeric literal or data item that specifies the number
of lines in the window. It must be a nonnegative integer.
5. title is a nonnumeric literal or alphanumeric data item.
6. save-area is an elementary data item described by a PICTURE X(10)
clause.
7. REVERSE and REVERSED are equivalent.
8. Exactly one of the SIZE or LINES phrases must be specified for a
Format 2 DISPLAY statement.
General Rules
All Formats
1. The LINE and COLUMN phrase
s must specify a line or column on the physical screen.
Format 1 (DISPLAY WINDOW)
2. The DISPLAY WINDOW statement creates and makes current a terminal
window. The terminal window is a rectangular region of your
screen. Any ACCEPT or DISPLAY statements (apart from another
DISPLAY WINDOW or ACCEPT or DISPLAY statement format as described
in your Language Reference ) affect only the current window.
Furthermore, line and column numbers for all ACCEPT and DISPLAY
statements (apart from another DISPLAY WINDOW or ACCEPT or DISPLAY
statement format as described in your Language Reference are
computed from the upper left hand corner of the current window.
That is, the current window defines a virtual terminal screen
which occupies some area of your virtual screen.
3. The initial window is set to the entire screen.
4. The only way to change the current window is with another DISPLAY
WINDOW statement or with the CLOSE WINDOW statement.
5. The LINE NUMBER phrase
sets the top line of the window. Line number one refers to the
top line of the screen. Line numbers are relative to the screen,
and not to the current window.
6. If the LINE NUMBER phrase is not specified, or zero, or off the
physical screen, the top line of the screen is used.
7. The COLUMN NUMBER phrase
sets the leftmost column of the window. Column number one refers
to the left side of the screen. Column numbers are relative to
the screen, and not to the current window.
8. If the COLUMN NUMBER phrase is not specified, or zero, or off the
physical screen, column number one is used.
9. The SIZE phrase
sets the number of columns the window will contain. If this
causes the window to extend past the right edge of the screen, the
window's width extends off the screen.
10. If the SIZE phrase is not specified, or zero, the window extends
to the right edge of the screen.
11. The LINES phrase
sets the number of rows the window will contain. If this causes
the window to extend past the bottom of the screen, the height
extends off the screen.
12. If the LINES phrase is not specified, or zero, the window extends
to the bottom edge of the screen.
13. When the ERASE phrase
is specified, the window will be cleared immediately after it is
created. Otherwise the window's contents will not be changed.
When a window is cleared, it is set to spaces.
14. The ERASE phrase is implied by the BOXED and REVERSED phrases.
15. The BOXED phrase
causes a box to be drawn around the new window. The box is drawn
outside the window. Any portions of the box that lie off the
screen will not be drawn.
16. The terminal's line drawing set is used to draw the box. If the
terminal does not have a line drawing set, equivalent ASCII
characters are used. If the POP-UP phrase
is also specified, the box will overlay any other boxes on the
screen. If this phrase is not specified, the box drawn will be
attached to any other boxes it intersects. Note that when a boxed
non pop-up window intersects a boxed pop-up window, if the pop-up
window is created first, when it is closed the points where the
two window boxes intersected will not be redrawn. That is,
intersection characters will remain even though there is no longer
an intersection.
17. The BOXED phrase implies the ERASE phrase.
18. The REVERSED phrase
exchanges to window's foreground and background colors. This will
affect every ACCEPT and DISPLAY statement in the new window.
19. The REVERSED phrase implies the ERASE phrase. Note that this will
usually cause the entire window to be set to reverse video spaces
when it is initially created.
20. The TITLE phrase
causes the title to be printed in the window's border. This has
its effect only if the BOXED phrase is also specified.
21. Titles can be placed in one of six positions in the border region:
top left, top center, top right, bottom left, bottom center and
bottom right. If TOP or BOTTOM is not specified, TOP is used. If
LEFT, CENTERED or RIGHT is not specified, CENTERED is used.
22. The POP-UP AREA phrase
causes your COBOL system to save system information prior to
creating the new window. This information can be used by the
CLOSE WINDOW
statement to subsequently remove the new window and restore the
underlying windows. This gives a "pop-up" window.
23. The save-area data item is filled in with system information.
This data item must not subsequently be modified in any way or
results will be undefined. It can be referenced in a CLOSE WINDOW
statement to restore an earlier window to the screen and
reestablish that window as the current window.
Format 2 (DISPLAY LINE)
24. The DISPLAY LINE
statement allows you to draw vertical and horizontal lines in a
machine- and terminal-independent manner. The lines are drawn
using the best mode available on the display device. Used
together with the DISPLAY BOX statement, this provides the ability
to draw forms on your screen. The DISPLAY LINE verb does not
affect the positioning of full screen ACCEPT and DISPLAY
statements.
25. Lines are drawn so that when they intersect other lines on the
screen, the appropriate intersection character is used. This is
done so that when the end of a line intersects another line, the
appropriate corner or three-way intersection is used.
26. If the SIZE phrase
is specified, the line drawn is horizontal. The value of length
gives the size of the line in screen columns. If the LINES phrase
is used instead, the line drawn is a vertical line and height
describes the number of screen rows to use.
27. Lines never wrap around or cause scrolling. If the LINES or SIZE
phrase would cause the line to leave the current window, the line
is truncated at the edge of the window. If LINES or SIZE is zero,
no line is drawn.
28. The value of line-num gives the starting row of the line. The
value of col-num gives the starting column. Lines are always
drawn to the right or downwards as appropriate. Line-num and
col-num must specify a position that is contained in the current
window.
29. If the LINE NUMBER
or COLUMN NUMBER
phrases specify a point outside the physical screen, that is,
column 0 or >80, or line 0 or >24 (or your screen maximum), no
line is drawn.
30. The TITLE phrase
has effect only when drawing horizontal lines. When specified,
title-string is printed in part of the line.
31. The title may be printed near the right side, near the left side
or in the center of the line depending on the RIGHT, LEFT or
CENTERED phrase specified. If none is specified, CENTERED is
used.
32. The REVERSE phrase
exchanges the foreground and background color of the line.
Format 3 (DISPLAY BOX)
33. The DISPLAY BOX
verb allows you to draw a box in a machine and terminal-independent
manner. The best drawing mode of the display device is used. If
the lines used in drawing a box intersect other lines already
present on the screen, the appropriate intersection characters are
used. The DISPLAY BOX verb does not affect the positioning of
full screen ACCEPT and DISPLAY statements.
34. The location of the box is specified by providing the location of
the upper-left corner. The size of the box is specified by
providing a height and a width.
35. If the LINE NUMBER or COLUMN NUMBER phrases specify a point
outside the physical screen, that is column >80, and line >24 (or
your screen maximum), no line is drawn.
36. The SIZE phrase specifies the width of the box. The LINES phrase
specifies its height. If the SIZE phrase is not specified, or
zero, or such that the box would extend beyond the physical
screen, the box will extend to the right edge of the current
window. If the LINES phrase is not specified, or zero, or such
that the box would extend beyond the physical screen, the box will
extend to the bottom of the current window.
37. The REVERSE phrase operates in the same manner as it does for a
DISPLAY WINDOW statement.
38. The TITLE phrase operates in the same manner as it does for the
DISPLAY WINDOW verb.
Windowing Restrictions
* This feature is not guaranteed to be intermediate code compatible,
so you may need to recompile your source code between product
releases.
* When using the ACCEPT or DISPLAY statements with this new
windowing syntax, you must include the AT LINE NUMBER
syntax (see your Language Reference) or the syntax will not appear
in the windows.
* You should not use cobprintf() with
these DISPLAY statements.
* You should not use COPY REPLACING
or REPLACE
statements.
* The following reserved words have been introduced by the windowing
syntax,
so you should avoid specifying them:
BOX
BOXED
CENTERED
POP-UP
WINDOW
* You should use only the ACCEPT and DISPLAY statements documented
in your Language Reference with this windowing syntax.
* When using windowing syntax, the ANS85 Compiler directive
is implied. You must not unset this directive either explicitly
or implicitly.
* Alphanumeric literals must not be continued over the end of any
line which includes a windowing statement.
* Some syntax errors, for example, spelling PROCEDURE DIVISION
incorrectly, will be flagged, but may result in spurious error
messages for the next source lines.
* You must not use windowing syntax
in nested programs or in programs which use nested COPY
statements.
* Windowing syntax errors
are serious errors, but are flagged in the form:
xnnn-P*******
* The -P cob flag should not be used with windowing syntax.
You should instead use "-C list".
* Column 73 must not be used within source programs which use
windowing syntax,
as this column is always treated as being set to a space
character.
* The Compiler asks if you wish to continue after any error occurs.
You can disable this function by using the NOERRQ directive. You
should not, however, use the NOERRQ directive when compiling from
within Toolbox.
If no error occurred, or if an error occurred but you replied "no"
to the question "do you wish to continue", the Compiler will
return a zero error return-code.
* Color is not supported within ACCEPT/DISPLAY Statements. Normal
attributes will be displayed.
* No part of the following statements may appear on the same line:
DISPLAY WINDOW
DISPLAY BOX
DISPLAY LINE
CLOSE WINDOW
EXIT PROGRAM
* The windowing subsystem is initialized automatically upon
encountering the first windowing
statement. When the windowing subsystem is loaded, color is not
supported at Run-Time (normal attributes will be displayed) and
non-windowing ACCEPT/DISPLAY performance may be slightly slower.
* The windowing subsystem can be implicitly and automatically
unloaded by an EXIT PROGRAM statement if you specify the
preprocessor directive AUTOCLOSE on an initial source line as
shown below:
$set preprocess"window1" autoclose
This causes all EXIT PROGRAM statements within that source module
to close down the windowing system before exiting the subprogram.
The windowing subsystem will be reinitialized upon encountering
another windowing statement. Note that each time it initializes,
the background screen and contents will be redisplayed.
You can create a subroutine to explicitly close the windowing
system by compiling the following subroutine:
$set preprocess"window1" autoclose
procedure division
para-1.
exit program.
You need simply call this subprogram.
* You should not mix calls to PANELS and calls to windowing syntax
within the same run-unit.
* When a window is active, or has been active in the run-unit, use
of the DISPLAY SPACES UPON CRT statement will clear the window to
spaces but will leave attributes unchanged.
Windowing Error Messages
The following errors may be encountered during windowing. An explanation
of the error will appear after the colon.
001 Unexpected numeric literal:
002 Unexpected alphanumeric literal:
003 Unsupported keyword or noiseword:
004 Unrecognized clause to DISPLAY WINDOW:
005 Unrecognized clause to DISPLAY LINE:
006 Unrecognized clause to DISPLAY BOX:
007 Unrecognized clause to ACCEPT FROM SCREEN:
008 This keyword has already been used:
009 This keyword conflicts with another:
010 This reserved word is used incorrectly:
011 Wrongly formed or ordered clause with keyword:
012 Error during preprocessing - no further details
The edit/compile/animate loop returns to an incorrect line within your
source program after returning an error.
Windowing Supplementary Information
When the first Windowing Statement in your program is encountered the
screen will be redisplayed. Please note that this is expected behavior
and does not affect your program in any way.
Demonstration Programs:
Two windowing and box drawing syntax demonstration programs, note.cbl
and calc.cbl,
are included in your software delivery. You can call both of these
programs from an application program, and you can also run them from the
command line. The note.cbl program implements a simple note pad which
you can call from an application in order to make notes, read or write
notes to a file, or invoke the calc.cbl program, which in turn implements
a simple on-screen calculator and pastes the results into the current
note.
In order to run the demonstration programs you should install your Micro
Focus COBOL software and copy the demonstration programs into a working
directory, and then compile them. You should enter:
cp $COBDIR/demo/WINDOW1/note.cbl
$COBDIR/demo/WINDOW1/calc.cbl .
cob -u note.cbl calc.cbl
If the COBDIR environment variable is not in use, you should substitute
/usr/lib/cobol in place of $COBDIR in the line above.
Ensure the Run-Time environment is set correctly: the environment
variable TERM must be set to reference the correct terminfo entry for
your terminal, and the stty settings must be able to handle 8-bit
characters if necessary. The demonstration uses line drawing characters
if supported, as well as normal video attributes and function keys. If
special line drawing characters are not available, suitable ASCII
characters will be used instead to provide an approximate rendition of
boxes and lines.
When you have compiled the demonstration programs, you can run the note
demonstration by entering:
cobrun note
A window will appear on your screen, into which you can enter notes using
the data keys, Enter key and arrow keys. In order to view the menu,
press Function key 1. From this you can use the arrow keys or the
letters to select an option from Escape, Load, Save or Calculator.
If you choose Calculator, a window representing a calculator appears. In
order to move straight to this window, you can enter:
cobrun calc
rather than cobrun note as above. Note that the calculator shows zero
prior to your entering each number. Enter the following:
256 * 4 - 8 =
The result of (256 x 4) - 8 = 1016 will be displayed. Press the Escape
key, and the calculator window disappears and 1016 is entered into the
note.
If you press Escape again, the note also disappears.
MPE/iX 5.0 Documentation