9 Output Operations

Display Enhancements

NOTE: Display Enhancements are available on the HP-UX platform, only.

The CURSOR Statement

The CURSOR statement allows program control of the display cursor and modification of a block of displayed characters. The syntax is as follows:

CURSOR item list

Any combination of these control items can be used:

(X pos, Y pos)
Cursor position.
IV
Set inverse video.
BL
Blinking character.
UL
Underline field.
HB
Set half bright display.
RE
Reset field enhancement.
PL
Protect lines.
UPL
Unprotect lines.
IF
Specify input field.
RIF
Reset input field.
OF
Specify output field.
ROF
Reset output field.
PALL
Protects all lines of the display buffer.
Each CURSOR item must evaluate to an integer greater than 0. There now follows a description of each control item.

The Eloquence Forms software provides additional CURSOR control items to assign input/output field numbers. See the Eloquence Forms Manual for details.

Set Cursor Position

(X pos,Y pos)

(X pos)

(Y pos)

This item allows the cursor to be positioned anywhere within the display buffer. The X position, if specified, determines the character position within a display line. An X position greater than 80 will "wrap around" to the second row of the same line. (Remember, the display buffer width is initially 160 characters but can be changed by using PRINTER IS.) If the X position is not specified, the current cursor X position will be used.

The Y position, if specified, determines the number of lines down from the HOME position, which is the top of the display buffer. Any Y position below the last line will add new lines as required. If it is not specified, the current Y position is used.

Note that the cursor must remain on the display at all times, so the display may scroll up or down appropriately to satisfy this condition. The cursor may be repositioned many times in a single CURSOR statement, with other functions being performed at the intermediate positions.

This program generates the same display as that illustrating the PAGE function, but CURSOR is used here in place of output functions:

10   CURSOR (1,1)
20   Column=1
30   FOR Line=1 TO 10
40     CURSOR (Column,Line)
50     DISP "Eloquence"
60     Column=Column+3
70   NEXT Line
80   END
Line 10 positions the cursor to the top of the display buffer, whereas the PAGE function in the earlier program only sets the cursor to the top of the next page of the buffer.

Here is a more practical example of CURSOR use:

The Assign routine assigns line-drawing characters to elements of a string array, one line per string. Then the Draw routine displays the strings to create the form. Notice that the CURSOR statements reposition the cursor before each DISP. Here is the resulting display:

CURSOR can also be used to accurately position the display cursor while adding each title to the form:

210 Add_titles: !
220      CURSOR (31,2)
230      DISP "IN-STOCK REPORT"
240      CURSOR (13,4)
250      DISP "Part No.";
260      CURSOR (27,4)
270      DISP "Description";
280      CURSOR (49,4)
290      DISP "On Hand"
300      CURSOR (67,4)
310      DISP "On";
320      CURSOR (66,5)
330      DISP "Order";
340      CURSOR (12,5)
350      DISP "XXXXX-XXXXX";
360      CURSOR (41,5)
370      DISP "Qty"
380      CURSOR (48,5)
390      DISP "Cost"
400      CURSOR (56,5)
410      DISP "Tot. Cost";
Notice that a semicolon follows each DISP statement here, to suppress additional spaces which may print over the line-drawing characters. (Unless you meticulously plan the position of each line-drawing and title character in advance, creating forms of this kind is, at best, a trial and error experience.)

Now the form looks like this:

The XPOS and YPOS Functions

XPOS

YPOS

These functions return numeric values according to the current cursor position. YPOS returns the current line number, relative to the first line of the display buffer (home). XPOS returns the character position of the cursor in the current line. Both values will always be greater than 0. These functions may be used anywhere in Eloquence expressions, but they are particularly useful in conjunction with the CURSOR statement for relative movement of the cursor or for monitoring user manipulation of the cursor.

Here is another version of the display program shown under the description of the PAGE function.

10   CURSOR (1,1)
20   FOR Line=1 TO 10
30     DISP "Eloquence";
40     CURSOR (XPOS-2,YPOS+1)
50   NEXT Line
60   END

Field Enhancements

These items affect the characters starting at the current cursor position. The parameter field length specifies the number of characters to be enhanced. The cursor will be left in its original position at the first enhanced character. The RE item cancels any previous enhancement items for the specified display field.

The characters used by the computer to control the display enhancements are supplied in page 383 .

Here is a program that demonstrates all of the field enhancements:

10          DISP "Cr/H Cl/S"  ! Cursor home and clear display.
20 Inverse: ! fill screen with inverse video fields.
30          FOR Line=1 TO 24
40          CURSOR (1,Line),IV(80)
50          DISP "INVERSE VIDEO"
60          NEXT Line
70 Halfbright: ! add fields in halfbright video.
80          WAIT 1000
90          FOR Line=2 TO 24 STEP 2
100         CURSOR (1,Line),HB(80)
110         DISP "HALF BRIGHT"
120         NEXT Line
130         WAIT 1000
140 Blinking: ! add alternate blinking fields.
150         FOR Line=2 TO 24 STEP 2
160         CURSOR (40,Line),BL(40)
170         DISP "BLINKING FIELD"
180         NEXT Line
190         WAIT 1000
200 Underline: ! add underlined fields.
210         FOR Line=1 TO 23 STEP 2
220         CURSOR (40,Line),UL(40)
230         DISP "UNDERLINED FIELD"
240         NEXT Line
250         WAIT 5000
260 Reset: ! reset all display enhancements.
270         FOR Line=1 TO 24
280         CURSOR (1,Line),RE(80)
290         NEXT Line
300         END
Line 10 sets the cursor at buffer home and clears the buffer. The Inverse routine fills the display with inverse video fields and labels each line. The Halfbright routine then fills every other line with half bright fields. The next two routines fill the right half of the display with blinking and underlined labels.

The display now looks like the following:

Finally, the last routine resets (clears) all field enhancements, leaving only the displayed labels.

The next program uses CURSOR to draw a box of inversed-video characters. Within the box is a blinking, underlined message.


10   DISP "Cr/H Cl/S"! Cursor home and clear screen
20   CURSOR (18,5),IV(44)
30   CURSOR (18,6),IV(44)
40   CURSOR (18,7),IV(2),(60),IV(2)
50   CURSOR (18,8),IV(2),(60),IV(2)
60   CURSOR (18,9),IV(2),(60),IV(2)
70   CURSOR (18,10),IV(2),(30),UL(20),BL(20),(60),IV(2),(30)
80   DISP "LINE DRAWING IS FUN!"
90   CURSOR (18,11),IV(2),(60),IV(2)
100  CURSOR (18,12),IV(2),(60),IV(2)
110  CURSOR (18,13),IV(2),(60),IV(2)
120  CURSOR (18,14),IV(44)
130  CURSOR (18,15),IV(44)
140  END
Here is the resulting screen:

Protect and Unprotect Lines

CURSOR (x,y) PL (number of lines)

CURSOR (x,y) UPL (number of lines)

CURSOR (x,y) PALL

CURSOR (x,y) UPALL

To prevent input or output fields on the screen from being overwritten, PL and PALL allow lines of the screen to be declared as unmodifiable, or protected. UPL and UPALL allow "unprotecting" screen lines. An unprotected line could be modified by the keyboard, a program, or the system. CURSOR PL(x) protects x number of lines starting with the current cursor position. PALL protects all lines in the display buffer.

CURSOR (x,y) PL(z) unprotects z number of lines starting with the current cursor position (x,y). CURSOR (x,y) UPALL unprotects lines in the current display buffer.

Note that protected lines will not be stripped from the top of the display buffer. This can be of use in fixing the HOME position if an absolute reference is desired for the cursor position function. However, the lines must then be explicitly unprotected to allow the system to recover unnecessary display areas.

Input and Output Fields

CURSOR (x,y) IF (field width)

CURSOR (x,y) OF (field width)

CURSOR (x,y) RIF (field width)

CURSOR (x,y) ROF (field width)

Fields within a line can be declared as input-only or output-only. IF, OF, RIF, and ROF work on lines that have been protected. (For more information on protected lines, refer to page 274 in this chapter.)

An input field can receive input from the keyboard only. Your program must not attempt to print in an input field. In the statement CURSOR (x,y) IF(z) there is an input field of length z starting at cursor position (x,y). In an INPUT or ENTER statement, one input variable is assigned to each input field. When entering the data, press TAB to move the cursor to the first character of the next input field. Press SHIFT TAB to move the cursor to the previous input field.

An output field can only receive output from the computer. Your program must not expect input from an output field. Each sequential output item goes to the next sequential output field or the next unprotected line, whichever comes first. After output to an output field, the cursor rests at the next character position until moved by another CURSOR, input, or output operation.

Output fields only receive output, such as from DISP, PRINT, and the prompt from an INPUT. Line output operations such as LIST, LDISP or CAT do not alter protected lines. The line output occurs on the next unprotected line.

The next example is part of a program to initiate new customer accounts. The New Customer form is first displayed; then underscores are used to fill the input fields. Then the input fields and one output field are defined. Line 210 protects the entire display page. The input-data routine suspends program execution to permit user entry and then enters data from each field using ENTERs. An account number is then assigned and placed in the output field with a DISP. The remainder of the program sets up the customer account.

10       DIM Name$[35],Address$[50],Zip$[5],Phone$[11]
20 Display_form:  !
30       DISP "                NEW CUSTOMER FORM    "
40       DISP "     NAME  ____________   ,  ____________   ,  ____________  "
50       DISP "           last               first            middle"
60       DISP "     ADDRESS  ____________  "
70       DISP "              street"
80       DISP "              ____________  ,  ____________  "
90       DISP "              city             state"
100      DISP "              ____________     ( ____________  )  ____________  "
110      DISP "              zip      telephone"
120      DISP "    ACCOUNT NO."
130      DISP " ____________  
140      DISP "ENTER INFORMATION INTO EACH BLANK FIELD. USE THE "
150      DISP "TAB KEY TO MOVE TO THE NEXT FIELD. PRESS ENTER WHEN COMPLETE"
160 Define_fields: !
170      CURSOR (11,5),IF(15),(29,5),IF(15),(47,5),IF(2)
180      CURSOR (14,8),IF(19),(14,11),IF(14),(31,11),IF(5)
190      CURSOR (14,14),IF(5),(23,14),IF(3),(28,14),IF(8)
200      CURSOR (19,19),OF(20)
210      CURSOR (1,1),PL(24)
220 Input_data: !
230      CURSOR (5,5)  ! Set cursor to first field.
240      INPUT         ! Allow operator to fill fields.
250      CURSOR (5,5)
260      ENTER Name$[1,15],Name$[16,30],Name$[31,32]
270      ENTER Address$[1,19]
280      ENTER Address$[20,34],Address$[35,39]
290      ENTER Zip$,Phone$[1,3],Phone$[4,11]
300      CURSOR (1,1),UPL(24)
310 Assign_account: !
320      READ #1;Account_no
330      CURSOR (19,19)! Set cursor at output fields.
340      DISP Account_no+1
350      PRINT #1;Account_no+1
360      CURSOR (1,1),UPL(24)
370 Open_file: ! Open new file on customer.
Notice that the cursor must be positioned at the beginning of each display input or output operation. See line 230, 250, and 330. Be sure to unprotect the display (line 300) after entering data to allow use of the display lines by other operations.

The form generated by this program is shown here:


Eloquence Language Manual - 19 DEC 2002