Professional Documents
Culture Documents
5
Screen Interaction Statements
Objectives
Column 1 Column 80
Row 1
Text
Row 24
Definition Before using the screen interaction statements, it is necessary to define exactly what
the screen is in Informix 4GL. The screen is that area of the terminal where
information can be displayed. By default, the area of the screen in Informix-4GL is
24 rows by 80 columns. Informix 4GL allows you to break the screen area into smaller
sections called windows.
Column 1 Column 50
Row 1
Row 15
Definition When you create a window in Informix 4GL, you are actually creating a mini-screen.
You are reducing the area in which statements can be placed. In the illustration
above, you would get an error if you tried to display a MESSAGE statement on row
16. As far as Informix 4GL is concerned, there is no row 16. Only one window or the
screen can be active at any given time. The last window to become active is
considered the current window.
The actual statements needed to create a window will be discussed in a different
module. What you need to know now is this:
n You can have as many windows as you want (memory is the only limitation).
n Only one window is active at a time.
n You can change the active window.
n You can decide what size to make a window.
n The size of a window can affect other Informix 4GL statements.
Syntax
MESSAGE display-list [ATTRIBUTE (attribute-list)]
Example
MESSAGE "Press the first letter of an option."
ATTRIBUTE (REVERSE)
Use the MESSAGE statement to display a character string on the Message line.
The default Message line is line two of the active window. You can change this
through the use of the OPTIONS statement. The OPTIONS statement will be
discussed later in this module.
Syntax
ERROR display-list [ATTRIBUTE (attribute-list)]
Example
ERROR "No Rows Found."
Default displays on
last line
No Rows Found.
Use the ERROR statement to display a character string on the Error line. The
default Error line is the last line of the screen. You can change this through the use
of the OPTIONS statement. The Error line is always relative to the screen,
regardless of the number of windows you have open. The ERROR statement
always displays text in reverse video and sounds the terminal bell.
Attributes
You may associate one or more attributes with the ERROR statement. An attribute
affects the way in which an error will be displayed. The following is a list of
attributes that can be used with the ERROR statement.
UNDERLINE REVERSE INVISIBLE BOLD
BLINK NORMAL DIM
No Rows Found.
It is worth pointing out that the ERROR and MESSAGE statements differ in two
distinct ways.
n An ERROR statement is always relative to the screen. A MESSAGE statement
is relative to a window (remember, if there are no windows open, the screen
becomes the current window).
n The ERROR statement always sounds the terminal bell.
For example, suppose that the defaults for Error line (last line of screen) and
Message line (second line of window) have not been changed. In the illustration
above, a window has been opened, and a MESSAGE statement and an ERROR
statement were encountered. Notice that the message text is inside the window and
the error text is at the bottom of the screen.
Syntax
DISPLAY "message" [AT row, column]
[ATTRIBUTE (attribute-list)]
Example
DISPLAY "Row Added." AT 22, 3
ATTRIBUTE(reverse)
Row Added.
Attributes
You can associate one or more attributes with the DISPLAY statement. The
following is a list of attributes that can be used with the DISPLAY statement.
UNDERLINE REVERSE INVISIBLE BOLD
BLINK NORMAL DIM
Warning If you specify a row or column location that does not exist because a window of
smaller dimension was opened, a runtime error occurs.
Example
Are you sure? Y/N
PROMPT "Are you sure? Y/N"
FOR CHAR answervar
The PROMPT statement differs from those previously discussed in that it not only
displays a line of text, but waits for the user to reply. The user's reply is stored in a
variable. The statements necessary for defining variables are covered in another
module. The default display for PROMPT is the first line of the window.
CENTURY
The new attribute available with version 7.3, CENTURY specifies how to expand
abbreviated one- and two-digit year specifications in a DATE and DATETIME
field. The CENTURY attribute is discussed in detail in the module about forms.
Example:
PROMPT "Enter the preferred delivery day. " FOR
del_day ATTRIBUTE (BOLD, CENTURY = "F")
...
END PROMPT
The OPTIONS statement is used to modify the default values associated with some
commands. For example, in a later module, you will learn how to create on-line
help in your program. By default, the help key is CONTROL-W. This can be
changed by listing a different help key in an OPTIONS statement, as shown here:
OPTIONS
HELP KEY "CONTROL-B"
You can have more than one OPTIONS statement in a program. Listed above are
some aspects of your code that can be affected by options that you set.
The MENU LINE option allows you to direct the menu lines to any lines of your
current screen or window. By default, menus are assigned to the first two lines of
the current screen or window. In the code below, the MENU LINE has been set to
LAST - 1. This positions the MAIN MENU at the bottom of the screen, as shown
above.
Either of the reserved words, FIRST or LAST, can be used with MENU LINE. The
values of FIRST and LAST are always relative to the current screen or window.
MAIN
CALL set_options()
CALL main_menu()
CLEAR SCREEN
END MAIN
FUNCTION set_options()
OPTIONS
MENU LINE LAST - 1
END FUNCTION
. . .
OPTIONS
MESSAGE LINE FIRST + 2,
ERROR LINE 23,
PROMPT LINE LAST -3
The OPTIONS statement is used to modify the default values associated with some
Informix-4GL statements. The default lines on which the MESSAGE statement, the
PROMPT statement and the ERROR statement display can be changed using the
OPTIONS statement.
FIRST, LAST
The FIRST and LAST keywords can be used to set a display line for the three
statements shown above. FIRST is equal to line 1. These keywords are especially
useful with the two statements, PROMPT and MESSAGE, that display in the active
window. For example, user prompts are always located at the next to last line in the
active window, no matter what the window size is, by setting the following in the
OPTIONS statement:
OPTIONS
PROMPT LINE LAST - 1
Note There can be multiple OPTIONS statements within an application. A setting
established in an OPTIONS statement stays in effect until that setting is changed in
another OPTIONS statement. If the OPTIONS statement for the default settings that
you wish to use for an application are contained in a separate function, you can re-
set the options to your defaults at any time by calling that function.
Exercise
Using the terminal shown to the left, draw a line in the approximate
location in which you think the MESSAGE in the code above will be
displayed.
What line number is this? ________
Using the terminal shown to the left, draw a line in the approximate
location in which you think the ERROR in the code above will be
displayed.
What line number is this? ________
Using the window shown on the terminal to the left, draw a line in the
approximate location in which you think the ERROR text in the code
above will be displayed, and where you think the MESSAGE text in the
code will be displayed.
Solution
Using the terminal shown to the left, draw a line in the approximate location in
which you think the MESSAGE statement in the code above will be displayed.
What line number is this? 3
Using the terminal shown to the left, draw a line in the approximate location in
which you think the ERROR statement in the code above will be displayed.
What line number is this? 24
Using the window shown on the terminal to the left, draw a line in the
approximate location in which you think the ERROR statement in the code
above will be displayed, and where you think the MESSAGE statement in the
code will be displayed.