Summary:
See also: Variables, Records, Windows, Forms, Record Input, Display Array
Programs retrieve data from the database into variables with a cursor or a static SELECT statement, and display the variable values to the current form with the DISPLAY instruction:
The DISPLAY TO instruction displays data to form fields explicitly.
DISPLAY expression [,...] TO field-list [,...]
[ ATTRIBUTE ( display-attribute [,...] ) ]
where field-list is :
{ field-name
| table-name.*
| table-name.field-name
| screen-array[line].*
| screen-array[line].field-name
|
screen-record.*
|
screen-record.field-name
}
[,...]
.*
notation.A DISPLAY TO statement copies the data from program variables to the form fields specified in the instruction.
Note that the DISPLAY TO statement changes the 'touched' status of the target fields. When you modify a field value with this instruction, the FIELD_TOUCHED() operator returns TRUE and the ON CHANGE trigger may be invoked if the current field value was changed with a DISPLAY TO. During an INPUT or INPUT ARRAY, we recommend you to use the UNBUFFERED attribute to display data automatically to fields without changing the 'touched' status of fields.
If the variables do not have the same names as the
form fields, you must use the
TO clause to explicitly map the variables to fields. You can list the
fields individually, or you can use the screen-record.*
or screen-record[n].*
notation, where
screen-record[n].*
specifies all the fields in line
n
of a screen array.
In a DISPLAY TO statement, any screen attributes specified in the ATTRIBUTE clause apply to all the fields that you specify after the TO keyword.
In the following example, the values in the p_items program record are displayed in the first row of the s_items screen array:
01
DISPLAY p_items.* TO s_items[1].*
The expanded list of screen fields must correspond in order and in number to the expanded list of identifiers after the DISPLAY keyword. Identifiers and their corresponding fields must have the same or compatible data types. For example, the next DISPLAY statement displays the values in the p_customer program record in fields of the s_customer screen record:
01
DISPLAY p_customer.* TO s_customer.*
For this example, the p_customer program record and the s_customer screen record require compatible declarations. The following DEFINE statement declares the p_customer program record:
01
DEFINE p_customer RECORD02
customer_num LIKE customer.customer_num,03
fname LIKE customer.fname,04
lname LIKE customer.lname,05
phone LIKE customer.phone06
END RECORD
This fragment of a form specification declares the s_customer screen record:
01
ATTRIBUTES02
f000 = customer.customer_num;03
f001 = customer.fname;04
f002 = customer.lname;05
f003 = customer.phone;06
END
The ATTRIBUTE clause temporarily overrides any default display attributes or any attributes specified in the OPTIONS or OPEN WINDOW statements for the fields. When the DISPLAY statement completes execution, the default display attributes are restored.
The following table shows the display-attributes supported by the DISPLAY TO statement. The display-attributes affect console-based applications only, they do not affect GUI-based applications.
Attribute | Description |
BLACK, BLUE, CYAN, GREEN, MAGENTA, RED, WHITE, YELLOW | The TTY color of the displayed data. |
BOLD, DIM, NORMAL | The TTY font attribute of the displayed data. |
REVERSE, BLINK, UNDERLINE | The TTY video attribute of the displayed data. |
The REVERSE, BLINK, INVISIBLE, and UNDERLINE attributes are not sensitive to the color or monochrome status of the terminal, if the terminal is capable of displaying these intensity modes. The ATTRIBUTE clause can include zero or more of the BLINK, REVERSE, and UNDERLINE attributes, and zero or one of the other attributes. That is, all of the attributes except BLINK, REVERSE, and UNDERLINE are mutually exclusive.
The DISPLAY statement ignores the INVISIBLE attribute, regardless of whether you specify it in the ATTRIBUTE clause.
See also DISPLAY AT.
The DISPLAY BY NAME instruction displays data to form fields explicitly by name.
DISPLAY BY NAME { variable | record.* } [,...]
[ ATTRIBUTE ( display-attribute [,...] ) ]
A DISPLAY BY NAME statement copies the data from program variables to the form fields associated to the variables by name.
Note that the DISPLAY BY NAME statement changes the 'touched' status of the target fields. When you modify a field value with this instruction, the FIELD_TOUCHED() operator returns TRUE and the ON CHANGE trigger may be invoked if the current field value was changed with a DISPLAY BY NAME. During an INPUT or INPUT ARRAY, we recommend that you use the UNBUFFERED attribute to display data to fields automatically without changing the 'touched' status of fields.
If the variables to be displayed have the same name as form fields, you can use the BY NAME clause. The BY NAME clause binds the fields to variables. To use this clause, you must define variables with the same name as the form fields where they will be displayed. The language ignores any record name prefix when matching the names. The names must be unique and unambiguous; if not, this option results in an error, and the runtime system sets STATUS to a negative value.
For example, the following statement displays the values for the specified
variables in the
form fields with corresponding names
(company
and address1
):
01
DISPLAY BY NAME p_customer.company, p_customer.address1
This BY NAME clause displays data to the screen fields of the default screen records. The default screen records are those having the names of the tables defined in the TABLES section of the form specification file. To use a screen array, you define a screen array in addition to the default screen record. This default screen record holds only the first line of the screen array.
For example, the following DISPLAY statement displays the ordno variable only in the first line of the screen array (the default screen record):
01
DISPLAY BY NAME p_stock[1].ordno
To display ordno in all elements of the screen array, you can use the DISPLAY ARRAY statement, or DISPLAY TO, as in the next example:
01
FOR i=1 TO 1002
DISPLAY p_stock[i].ordno TO sc.stock[i].ordno03
...04
END FOR
The following table shows the display-attributes supported by the DISPLAY BY NAME statement:
Attribute | Description |
BLACK, BLUE, CYAN, GREEN, MAGENTA, RED, WHITE, YELLOW | The color of the displayed data. |
BOLD, DIM, NORMAL | The font attribute of the displayed data. |
REVERSE, BLINK, UNDERLINE | The video attribute of the displayed data. |
See also DISPLAY AT.
The CLEAR FORM instruction clears all fields in the current form.
CLEAR FORM
01
MAIN02
OPEN WINDOW w1 AT 1,1 WITH FORM "custlist"03
CLEAR FORM04
CLOSE WINDOW w105
END FOR
See also CLEAR WINDOW, CLEAR SCREEN.
The CLEAR field instruction clears specific fields in the current form.
CLEAR field-list
where field-list is :
{ field-name
| table-name.*
| table-name.field-name
| screen-array[line].*
| screen-array[line].field-name
|
screen-record.*
|
screen-record.field-name
}
[,...]
01
FOR i=1 TO 1002
CLEAR s_items[i].*03
END FOR