You are on page 1of 18

Module

5
Screen Interaction Statements

Objectives

At the end of this module, you will be able to:


n Describe the features of the following Informix 4GL statements
w ERROR
w MESSAGE
w DISPLAY
w PROMPT
n Modify default display characteristics for these statements using the
OPTIONS statement

Screen Interaction Statements 1217 07-00 5-1


 2000 Informix Software, Inc.
The Screen

Column 1 Column 80

Row 1

Text

Row 24

Screen Interaction Statements 1217 07-00 2

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.

Redefining the Screen


It is possible to change the size of the screen. For example, if you are using a
workstation that will allow a larger form to be displayed, a bigger screen size can be
specified. How this is done will be covered in another module.
Note An X-term window is considered to be a screen.

Screen Interaction Statements 5-2


The Window

Column 1 Column 50

Row 1

Row 15

Screen Interaction Statements 1217 07-00 3

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.

Screen Interaction Statements 5-3


The MESSAGE Statement

Syntax
MESSAGE display-list [ATTRIBUTE (attribute-list)]

Example
MESSAGE "Press the first letter of an option."
ATTRIBUTE (REVERSE)

Press the first letter of an option.


Default location of
the MESSAGE
statement is line 2.

Screen Interaction Statements 1217 07-00 4

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.

Erasing the Message


The message will remain on the screen until another MESSAGE statement is used.
This means the only way to clear a message is to display another message of zero or
more characters. For example:
MESSAGE "No more rows in that direction."
SLEEP 3
MESSAGE ""
These statements would display a message to the screen, wait for three seconds, and
then erase the message. This is a very common usage of the MESSAGE statement.
SLEEP statements can be very annoying to users, so use them sparingly.

Screen Interaction Statements 5-4


Attributes
You can associate one or more attributes with the MESSAGE statement. An attribute
affects the way in which a MESSAGE will be displayed. The following is a list of
attributes that can be used with the MESSAGE statement.
UNDERLINE REVERSE INVISIBLE BOLD
BLINK NORMAL DIM
If your terminal supports color display, you can have the message appear in different
colors. Refer to the Informix 4GL Reference Manual for a listing of the color
attributes.

Screen Interaction Statements 5-5


The ERROR Statement

Syntax
ERROR display-list [ATTRIBUTE (attribute-list)]

Example
ERROR "No Rows Found."

Default displays on
last line
No Rows Found.

Screen Interaction Statements 1217 07-00 6

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.

Erasing the ERROR


An error message remains on the screen until another key is pressed by the user.

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

Screen Interaction Statements 5-6


ERROR vs. MESSAGE

MESSAGE "Press the first letter of an option."

Press the first letter of an option.

No Rows Found.

ERROR "No Rows Found."

Screen Interaction Statements 1217 07-00 7

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.

Screen Interaction Statements 5-7


The DISPLAY Statement

Syntax
DISPLAY "message" [AT row, column]
[ATTRIBUTE (attribute-list)]

Example
DISPLAY "Row Added." AT 22, 3
ATTRIBUTE(reverse)

Row Added.

Screen Interaction Statements 1217 07-00 8

Use the DISPLAY statement to display a character string to a specific location on


the screen. This is different from the MESSAGE statement which always starts in
the left margin of the MESSAGE line. With DISPLAY, you specify exactly where
you want your message to be displayed by giving a row and column location. If no
row and column location is specified, DISPLAY will display your message where
the cursor is currently pointing.

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.

Screen Interaction Statements 5-8


The PROMPT Statement
Syntax
PROMPT "message" [ATTRIBUTE (attribute-list)]
FOR [CHAR] variable
[HELP help-no]
[ATTRIBUTE (attribute-list)]
[ON KEY (key-list)
statement . . .]
END PROMPT

Example
Are you sure? Y/N
PROMPT "Are you sure? Y/N"
FOR CHAR answervar

Screen Interaction Statements 1217 07-00 9

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.

The CHAR Option


When Informix-4GL encounters a PROMPT statement, it will wait for the user to enter
a response and press RETURN. If the CHAR option is used, the PROMPT statement
expects the variable to be defined as a single character, and will not wait for
RETURN to be pressed.

The HELP # Option


You can also associate a Help number with a PROMPT statement. A Help number
will find the numbered message created using the mkmessage utility and display it
to the user when the Help key ( CONTROL-W by default) is pressed. The mkmessage
utility is covered in another module.

The ON KEY Option


The ON KEY option is used to define an action that will occur when the key listed
in the key-list is pressed. Specific uses of the ON KEY clause are discussed in
another module.

Screen Interaction Statements 5-9


Attributes
You can associate two sets of attributes with the PROMPT statement. The first
attribute applies to the message; the second attribute is for the variable or user’s
response to the PROMPT statement.
A list of attributes that can be used with the PROMPT statement is shown below.

UNDERLINE REVERSE INVISIBLE BOLD


BLINK NORMAL DIM CENTURY

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

Screen Interaction Statements 5-10


The OPTIONS Statement

The OPTIONS statement can be used to change default values


associated with some commands. Defaults that can be
changed include:
n The line error messages are displayed on
n The line messages are displayed to
n The help key
n The location of user prompts
n The location of menus

Screen Interaction Statements 1217 07-00 11

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.

Screen Interaction Statements 5-11


Options: MENU LINE

Use the MENU LINE


option to designate the
line on which a menu
displays.

MAIN MENU: Customer Orders Stock Reports Exit


Go to the CUSTOMER menu.

Screen Interaction Statements 1217 07-00 12

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
. . .

Screen Interaction Statements 5-12


Changing Defaults

The default lines on which these


statements display can be changed
using the OPTIONS statement.

OPTIONS
MESSAGE LINE FIRST + 2,
ERROR LINE 23,
PROMPT LINE LAST -3

Screen Interaction Statements 1217 07-00 13

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.

Screen Interaction Statements 5-13


True or False

All of the screen interaction statements are relative


to a window. ______
The ERROR statement will stay on the screen
unless the programmer does something to erase it. ______
The MESSAGE statement will always sound the
terminal bell and display in reverse video. ______
The user must always enter a RETURN in
response to a PROMPT statement. ______

Screen Interaction Statements 1217 07-00 14

Classify the statements shown above as true or false.

Screen Interaction Statements 5-14


Exercise
MAIN
OPTIONS MESSAGE LINE FIRST + 2
MESSAGE "Press the first letter of the option you want."
MENU "MAIN MENU"
COMMAND "Customer" "Go to the Customer menu."
CALL dummy()
COMMAND "Orders" "Add a new order."
CALL dummy()
COMMAND "Exit" "Exit to the O.S."
EXIT MENU
END MENU
END MAIN
FUNCTION dummy()
ERROR "Function not yet implemented."
END 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.

Screen Interaction Statements 5-15


Solutions
True or False Solutions

All of the screen interaction statements are relative


to a window. F
The ERROR statement will stay on the screen
unless the programmer does something to erase it. F
The MESSAGE statement will always sound the
terminal bell and display in reverse video. F
The user must always enter a RETURN in
response to a PROMPT statement. F

Screen Interaction Statements 1217 07-00 18

The solutions to the true or false statements are shown above.

Screen Interaction Statements 5-18


Solution
Solution
Solution MAIN
OPTIONS MESSAGE LINE FIRST + 2
MESSAGE "Press the first letter of the option you want."
MENU "MAIN MENU"
COMMAND "Customer" "Go to the Customer menu."
CALL dummy()
COMMAND "Orders" "Add a new order."
CALL dummy()
COMMAND "Exit" "Exit to the O.S."
EXIT MENU
END MENU
END MAIN
FUNCTION dummy()
ERROR "Function not yet implemented."
END FUNCTION

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.

Screen Interaction Statements 5-19

You might also like