If the names of the variables and the names of the fields differ, you should use TO clause instead of BY NAME clause. The DISPLAY statement with the TO clause has the following structure:
Display value |
An actual value enclosed in the double quotation marks, a variable which value is to be displayed or their combination separated by comas |
Field list |
A list of individual form fields, screen records and their members or screen arrays and their elements |
ATTRIBUTE clause |
An optional ATTRIBUTE clause which affects the display attributes applied to the Display Value |
You can list the fields individually or you can use screen records or screen arrays, either way they should be separated by commas. You can use the screen_record.* notation to specify all the fields of a screen record, or you can use the screen_array[i].* notation to specify all the fields within the i line of a screen array. However, the DISPLAY ARRAY statement is more convenient for displaying information to screen arrays.
If an ATTRIBUTE clause is present within the DISPLAY statement, the attributes will be applied to all the fields specified in the TO clause, or implied by the BY NAME clause.
In the example below, all the variables that belong to a program record are displayed to a screen record. The order of the fields in the screen record must be the same as the order of the variables within the program record. They also should correspond to each other in number and their data types should be the same or compatible, but they need not have the same names as in the case with the BY NAME clause.
DISPLAY pr_rec.* TO scr_rec.*
DISPLAY...TO can be used to change the runtime appearance of buttons and labels.
To change the text of a button or a label, you display the necessary text to it:
DISPLAY "new text" TO lb1
To change the image of a button or a label, you display the URI of this image:
DISPLAY "qx://application/image.svg" TO lb1
However, what you get at runtime depends on what you have in your form already.
DISPLAY "new text" TO lb1
DISPLAY "qx://application/image.svg" TO lb1
before the display:
after the display:
To be able to change the button/label image at runtime by DISPLAY...TO, you do need the image to be set as such.
What you need is the <*.image></*.image>
XML element added to your .fm2 form:
<Label.image>
<Image/>
</Label.image>
DISPLAY "qx://application/image.svg" TO lb1
before the display:
after the display:
DISPLAY "new text" TO lb1
before the display:
after the display:
before the display:
after the display:
DISPLAY "new text" TO lb1
DISPLAY "qx://application/image.svg" TO lb1
You can remove the text or image from a button or label at runtime by displaying this string to the widget:
With some widgets - like buttons and checkboxes, - you can use DISPLAY...TO to enable/disable them at runtime:
secures the default state - like enable set to unknown in LFD:
enables the widget - like enable set to true in LFD or CALL var.SetEnable(TRUE)
:
disables the widget - like enable set to false in LFD or CALL var.SetEnable(FALSE)
: