Using Panels | Presentation Manager Applications (16-bit) |
Your COBOL system supports syntax which enables you to draw lines and boxes on the terminal screen, and create virtual terminal windows on a physical terminal. All ACCEPT and DISPLAY statements then act within the current window (except for ACCEPT format 1, 2, or 3 statements, DISPLAY format 1 statements, and DISPLAY WINDOW/LINE/BOX statements). The syntax also enables underlying displays to be kept and restored.
Your COBOL system includes the following syntax to support windowing:
DISPLAY WINDOW creates a terminal window (a rectangular region of the screen) and makes it the current window. This is like a virtual terminal, in which screen positions used by subsequent ACCEPT/DISPLAY statements are relative to the top left corner of the window.
DISPLAY LINE enables you to draw lines on the terminal (real or virtual). The best mode available on the terminal is used automatically. Used with the DISPLAY BOX statement, the DISPLAY LINE statement enables you to draw lines on the terminal.
DISPLAY BOX enables you to draw boxes on the terminal. The best mode available on the terminal is used automatically. Used with the DISPLAY LINE statement, the DISPLAY BOX statement enables you to draw forms on the terminal.
CLOSE WINDOW removes a window. If you specify the window as being a POP-UP window, the underlying display can be restored.
In order to use the windowing syntax, you must use the PREPROCESS"WINDOW1" Compiler directive. For the UNIX operating system the directive must be specified in lower case ("window1"). See your Object COBOL User Guide for full details on specifying Compiler directives.
You can specify this directive in one of two ways.
$SET preprocess"window1"
DOS, Windows and OS/2:
For example, on DOS enter:
xm cobol prog.cbl preprocess "window1";
UNIX:
or on UNIX enter:
cob -C preprocess=window1 prog.cbl
The PREPROCESS "WINDOW1" directive must be the last Compiler directive apart from NOERRQ, AUTOCLOSE or COLOR. If an error is encountered, the Compiler asks 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".
UNIX:
On the UNIX operating system, if you create a new RTS that is to
make use of windowing syntax, you must include the -I COBWIN2 flag on the
command line. The following is an example of a command line you could use
to create a new RTS to include windowing support:
cob -x -I COBWIN2 -o rts.new
See the chapter Descriptions of cob Flags in your Object COBOL User Guide for more information on the use of the -I cob flag.
The following sections give details of the windowing syntax enabled by the PREPROCESS "WINDOW1" directive.
The CLOSE WINDOW statement closes the current video terminal window.
CLOSE WINDOW window-save-area
window-save-area
must be an elementary data
item described with a PIC X(10) clause. It must have been the object of
a POP-UP AREA phrase in a DISPLAY WINDOW statement. 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 can it have been modified by
any other statement. Violation of these rules causes undefined results.
The current window is selected by closing windows identified by their
respective window-save-area
data items, as in the
following example:
If five popup windows are created, a
, b
,
c
, d
and e
in that order:
d
is closed, c
becomes
current.
b
is then closed, a
becomes current.
e
is subsequently closed, c
becomes current again. This section explains COBOL windowing, which provides three additional formats of the DISPLAY verb for creating windows and drawing lines and boxes. Other formats are described in your Language Reference.
line-num
is a numeric literal or data item that
specifies the line position on the terminal screen. It must be a
nonnegative integer.
col-num
is a numeric literal or data item that
specifies the column position on the terminal screen. It must be a
nonnegative integer.
length
is a numeric literal or data item that
specifies the window-width, line-width or box-width in character
positions. It must be a nonnegative integer.
height
is a numeric literal or data item that
specifies the number of lines in the window, line or box. It must be a
nonnegative integer.
title
is a nonnumeric literal or alphanumeric
data item.
save-area
is an elementary data item described
by a PIC X(10) clause.
identifier-1
, identifier-2
,
integer-1
and integer-2
must
take a value in the range 0-7 as follows:
0 | black |
1 | blue |
2 | green |
3 | cyan |
4 | red |
5 | magenta |
6 | brown or yellow |
7 | white |
identifier-3
and integer-3
must take a value which is obtained by adding together the appropriate
values from the following:
Color |
Foreground |
Background |
---|---|---|
Black | 1 | 32 |
Blue | 2 | 64 |
Green | 3 | 96 |
Cyan | 4 | 128 |
Red | 5 | 160 |
Magenta | 6 | 192 |
Brown | 7 | 224 |
White | 8 | 256 |
Note: The foreground color values for use with the COLOR clause are different from the standard Micro Focus color values for; FOREGROUND-COLOR, BACKGROUND-COLOR and so on.
In addition you can specify the following video attributes with the following values:
Reverse video | 1024 |
Low intensity | 2048 |
High intensity | 4096 |
Underline | 8192 |
Blink | 16384 |
save-area
data item is filled in with
system information. This data item must not be subsequently modified in
any way or results are undefined. It can be referenced in a CLOSE WINDOW
statement to restore an earlier window to the screen and re-establish
that window as the current window. 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.
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 downward as appropriate.
line-num
and col-num
must
specify a position that is contained in the current window.
line-num
= 0 or 24 (or your screen's maximum), or
col-num
= 0 or > 80, no line is drawn.
title-string
is printed in part of the line.
-I COBWIN2
See the chapter Descriptions of cob Flags in your Object COBOL User Guide for more information on the use of the -I cob flag.
BOX
BOXED
CENTERED
POP-UP
WINDOW
COLOR (if COLOR directive used)
xnnn-P*******
If no error occurred, or if an error occurred but you replied "no" to the question "do you wish to continue", the Compiler returns a zero error return-code.
DISPLAY WINDOW
DISPLAY BOX
DISPLAY LINE
CLOSE WINDOW
EXIT PROGRAM
$set preprocess "window1" autoclose
This causes all EXIT PROGRAM statements within that source file to close down the windowing system before exiting the subprogram. The windowing subsystem is reinitialized upon encountering another windowing statement. Each time the windowing subsystem initializes, the background screen and contents are 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.
COPY filename OF library
is not supported.
The following errors might be encountered during preprocessing windowing.
The edit/compile/animate loop returns to an incorrect line within your source program after returning an error.
When the first windowing statement in your program is encountered the screen is redisplayed. This is expected behavior and does not affect your program in any way.
Two windowing and box drawing syntax sample programs, mfwnote.cbl and mfwcalc.cbl , are included in this COBOL system. You can call both of these programs from an application program, and you can also run them from the command line. The mfwnote.cbl program implements a simple notepad which you can call from an application in order to make notes, read or write notes to a file, or invoke the mfwcalc.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, copy them into a working directory, and then compile them. The following examples assume that you have installed the COBOL system in c:\cobol on DOS, Windows or OS/2, or /usr/lib/cobol on UNIX, and asked for demonstration programs to be installed.
copy c:\cobol\demo\window1\mfwnote.cbl copy c:\cobol\demo\window1\mfwcalc.cbl xm cobol mfwnote.cbl; xm cobol mfwcalc.cbl; link mfwnote+mfwcalc+adis+adisinit+adisdyna+adiskey+panels+ cobwin2,,,coblib+cobapi;
If you want to link Mfwcalc on its own enter:
link mfwcalc+adis+adisinit+adisdyna+adiskey+panels+cobwin2,,, coblib+cobapi;
Windows:
To link both mfwnote.obj and mfwcalc.obj for use on
Windows, enter:
16-bit for Windows:
link mfwnote+mfwcalc+cblwina+adis+adisinit+adisdyna+adiskey+ panels+cobwin2,,,coblibw+coblib+cobw+deffile.def/nod/noe;
32-bit for Windows:
cbllink mfwnote mfwcalc cobwin2 panels
and to link mfwcalc.obj on its own for use on Windows, enter:
link mfwcalc+cblwina+adis+adisinit+adisdyna+adiskey+panels +cobwin2,,,coblibw+coblib+cobw+deffile.def/nod/noe;
where, in both cases, deffile.def contains the lines:
exetype windows 3.1 protmode code preload fixed data preload fixed multiple stacksize 16384 heapsize 1024
DOS:
To run from a DOS command line, enter:
win mfwnote
or
win mfwcalc
Windows:
To run from Windows, select the Run dialog from the File
menu, and, assuming your working directory is c:\work, enter:
c:\work\mfwnote
or
c:\work\mfwcalc
OS/2:
To link both mfwnote.obj and mfwcalc.obj for use on
OS/2, enter:
link mfwnote+mfwcalc+adis+adisinit+adisdyna+adiskey+panels +cobwin2,,,coblib+os2;
To link mfwcalc.obj on its own for use on OS/2, enter:
link mfwcalc+adis+adisinit+adisdyna+adiskey+panels +cobwin2,,,coblib+0s2;
UNIX:
On UNIX enter:
cp $COBDIR/demo/WINDOW1/mfwnote.cbl . cp $COBDIR/demo/WINDOW1/mfwcalc.cbl . cob -u mfwnote.cbl mfwcalc.cbl
When you have compiled the demonstration programs, you can run the notepad demonstration by entering one of the following.
DOS and OS/2:
On DOS and OS/2 enter:
mfwnote
Windows:
On Windows select the Run dialog from the File menu,
and, assuming your working directory is c:\work, enter:
c:\work\mfwnote
UNIX:
On UNIX, fisrt ensure the run-time environment is set correctly: the
TERM environment variable 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 are used instead to provide an approximate rendition of boxes
and lines. Then, enter:
cobrun mfwnote
A window appears on your screen, into which you can enter notes using the data keys, Enter and the cursor keys (<left-arrow>, <right-arrow>, <up-arrow>, <down-arrow>). To view the menu, press F1. From this you can use the cursor keys or the letters to select an option from Escape, Load, Save or Calculator. If you choose Calculator, a window representing a calculator appears.
You can run the calculator demonstration without the notepad demonstration by entering one of the following.
DOS:
From a DOS command line, enter:
win mfwcalc
DOS and OS/2:
On DOS and OS/2 enter:
mfwcalc
Windows:
On Windows select the Run dialog from the File menu,
and, assuming your working directory is c:\work, enter:
c:\work\mfwcalc
UNIX:
On UNIX enter:
cobrun mfwcalc
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 is displayed. Press Escape, and the calculator window disappears and 1016 is entered into the note.
If you press Escape again, the note also disappears.
Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.
Using Panels | Presentation Manager Applications (16-bit) |