Consultor Eletrônico



Kbase 13432: How to convert version 6 TTY application to version 7 GUI.
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
How to convert version 6 TTY application to version 7 GUI.

This Knowledgebase talks about problems Technical
Support encounters when converting an application
written in Progress version 6 character (called TTY
in version 7) to run under Progress version 7 GUI,
i.e. MS-Windows or Motif. The error messages seen
when trying to compile the programs include, but
are not limited to:

"** Cannot fit EXPRESSION .. within FRAME . (4027)"
"** EXPRESSION will not fit in FRAME . (4028)"

Below is a description of why this may occur, as well as
some suggestions as to how to solve these conversion
problems.

First, "PUT SCREEN" is not supported in a GUI environment.
There is no guarantee that it will function the same way
as version 6. "PUT SCREEN" assumes complete control of the
screen/window; In MS-Windows & Motif, a window manager
intercedes and thus PROGRESS no longer has full control
of the window.


PROBLEM DESCRIPTION:
====================

The default FRAME size in version 6 depends upon
the platform. Running the following program:

/* Program: rows.p */
DEFINE VARIABLE I AS INTEGER NO-UNDO.
REPEAT: I = I + 1. DISPLAY I. END.

gives 17 rows in the default frame in a xterm
environment. Thus, version 6 defaults to 21 rows
by 80 columns plus 2 lines of message area plus
1 line for system messages. However, on a DOS
platform, you have 25 lines, and the above
program displays 18 lines in the frame.

In version 7 GUI, i.e. MS-Windows & Motif, layouts
of frames are different from version 6, in order
to comply with GUI standards. Thus, running program
"rows.p" in GUI will give 19 entries in the
default frame, because the upper and lower part
of the box in the frame no longer occupies a row.

Version 6 data types are converted to version 7
FILL-IN widgets when displayed on the screen.
Thus, version 7 GUI can only display up to 78
characters in the default frame, because it needs
room to display the "default" border around the
FILL-IN in conjunction with the "default" FRAME
border.

Thus, when converting a version 6 TTY application
into version 7 GUI, the FILL-IN widget can fail to fit
either vertically (row) and/or horizontally (column).

Example showing the 78 character problem:

/* char80_6.p */
DEF VAR hdr-1 AS CHAR FORMAT "x(80)" NO-UNDO.
DEF VAR thead AS CHAR INIT "HELLO" NO-UNDO.
FORM
HEADER "Date :" TODAY thead AT 38
"Time :" AT 60 STRING(TIME,"hh:mm am") AT 68
FILL("-",80) FORMAT "x(80)" SKIP
hdr-1 SKIP
FILL("=",80) FORMAT "x(80)" SKIP(1)
WITH FRAME A
PAGE-TOP 1 DOWN NO-BOX.
VIEW FRAME A.

The above program works fine in all of version 6,
and version 7 TTY mode, but fails in version 7 GUI
with error (4028):
"** EXPRESSION will not fit in FRAME A"

Again, the reason is that the program is trying to
display 80 character fields, but the default frame can
only handle 78 characters.


SOLUTIONS.
==========

Version 7 on the MS-Windows platform has an .INI file,
which is standard in the MS-Windows environment, to
specify fonts & colors and other settings for running
that application. This is called the "PROGRESS.INI" file.
One of the settings in this file is called "V6Display"
and is defined under the "[Startup]" section in the
beginning of the file. Specifying:
V6Display=yes
will enable the Progress session to run in a "pseudo"
version 6 mode. When this session attribute is turned
on, the following changes take place inside PROGRESS:

- The height of a PPU is recalculated to be the height
of the font specified by the "DefaultV6UpdateFont"
setting in the [Startup] section of the .INI file.
If the setting is not present, the default is the height
of the FIXEDSYS font. (The PPU height determines the
number of pixels that occupy a single ROW).

- The width of a PPU is recalculated to be the width
of the average character of the font specified by the
"DefaultV6UpdateFont" setting in the [Startup] section.

- All PROGRESS fillins are created without a border.

- Trailing spaces are not removed from any character
FILL-IN.

- UPDATE-able fields are visualized using the
"DefaultV6UpdateFont" which contains the underline
attribute. This causes all FILL-IN fields to be drawn
with underlines when they are being updated.

- Frame titles are drawn specially so that the frame
title height takes up exactly one PPU.
However, V6DISPLAY setting will cause adverse visual
effects for any V7 code that is also running that has
not been compiled with the V6DISPLAY switch. This
includes, but is not limited to, all of the V7 ADE
tools. While the core part of the editor is functional,
all of its dialog boxes will NOT appear correctly.

Program "rows.p" displays 19 entries, and "char80_6.p"
runs without any errors (with V6Display=yes).

V6Display should be used only on versions where "V6Frame"
(see discussion further below) is not available, i.e.
version 7.2D (and to some degree 7.2E).

With V6Display enabled all the GUI functionality is lost,
and this solution does not apply to the Motif environment,
because the program can be run in character mode on Unix
platforms.

***********************************************************

Another approach to solve this problem, which gives
version 7 GUI functionality, and can be applied to
the Motif platform will be discussed now. Please note,
that this discussion below has V6Display=no for MS-Windows
environments.

First, it is necessary to create a new window, instead of
using the default window. This is achieved by an include
file called "ver7.i":

/* ver7.i */
DEF VAR win AS WIDGET-HANDLE.
CREATE WINDOW win ASSIGN
HEIGHT = 22
WIDTH = 82.
CURRENT-WINDOW = win.

This will enable us to display a FILL-IN with
80 characters in a full GUI mode (i.e. there will
be room enough to enable the borders). The only
change needed to the main program, is to add one
line in the top as follows:
{ver7.i}

However, there is still more to be done. The "FORM" will
fail to compile, because, by default, frames only
contains 80 characters. It is necessary to add another
include file for each FORM statement to prevent
the compiler from generate error message (4028).
This include file is called "size7.i" and contains:
WIDTH 82
and is applied after the
"WITH FRAME [NAME] {size7.i}"
Thus, our "char80_6.p" program will now be called
"char80_7.p":

/* char80_7.p */
{ver.i}
DEF VAR hdr-1 AS CHAR FORMAT "x(80)" NO-UNDO.
DEF VAR thead AS CHAR INIT "HELLO" NO-UNDO.
FORM
HEADER "Date :" TODAY thead AT 38
"Time :" AT 60 STRING(TIME,"hh:mm am") AT 68

FILL("-",80) FORMAT "x(80)" SKIP
hdr-1 SKIP
FILL("=",80) FORMAT "x(80)" SKIP(1)
WITH FRAME A {size7.i}
PAGE-TOP 1 DOWN NO-BOX.
VIEW FRAME A.
PAUSE.

This will run, but might still look not quite as required,
because the fonts used are proportional, and this was
developed under a fixed font (v6). To solve this problem,
a new feature has been included in Progress 7.3A and
higher. It is called "V6Frame", and can be used either
as a startup parameter (in 7.2E), in the compile statement,
or in the FORM/DEFINE FRAME statement. Using "V6Frame"
as startup parameter (in the .INI file), causes the
entire session to handle all frames as V6Frames, and
would disable the functionality; to convert the programs
to version 7 GUI one step at a time. Two options are
recommended (with V6Frame option available):

1. COMPILE char80_7.p V6FRAME SAVE.
RUN char80_7.r

2. Change the include file {size7.i} to:
WIDTH 82 V6FRAME

Again, "V6Frame" puts the borders back on for the
FILL-INs. The font used to display "V6Frame" is "font3"
defined either in the "PROGRESS.INI" (MS-Windows) or
".Xdefalts" (Motif).

Now, since FONT can be specified in a FORM/DEFINE FRAME
statement, we can include the "V6Frame" functionality in
the {size7.i} include file:

/* size7.i */
FONT 3 WIDTH 82

This approach applies to all GUI versions of Progress 7!

Of course, "font3" has to be a fixed sized font. Examples
of fonts available in MS-Windows to choose from:
font3=Courier New, size=8
font3=Courier New, size=9
font3=MS LineDraw, size=8
depending on the resolution available on the MS-Windows
system.

The application is still portable to version 6
environments by applying these changes: All that is
required in the version 6 environment are two empty files,
called "ver7.i" and "size7.i".


Progress Software Technical Support Note # 13432