The Display Block
The display statement is followed by groups of statements that define the operations associated with the displayed form. The statements associated with the display of a single form constitutes that form's display block. The statements in the display block are divided into sections, each of which performs a separate function. There are three types of sections:
The initialize section
This section initializes the form. It begins with the initialize statement, which must be located immediately after the display statement. The initialize section can transfer data into the form when the form is first displayed. It can also include a block of initialization code that is executed when the form is first displayed.
The activate section
This section provides an operation, which the user can choose to run. A display block can contain numerous activate sections. Each activate section begins with the activate statement and includes a block of code that is executed when the user performs the specified action. This action can include selecting a menu item, pressing a specified key, or simply failing to perform any action for a specified period of time (an activate timeout).
The finalize section
This section must be the last in the display block. It contains only the finalize statement. The finalize statement can be used to transfer data from the form into program variables immediately prior to the end of the display loop. Unlike the other sections, no block of code can be associated with it.
All the sections are optional but, if included, must appear in the order described. A display block can include many activate sections, but only one initialize and one finalize section. The initialize and activate sections can have associated blocks of code, bounded by the exec frs begin and exec frs end statements (exec frs is specific to SQL). You can place any appropriate host language or embedded query language statement between the begin and end statements.
All statements within a display block must be part of an initialize, activate, or finalize section. A statement appearing outside a section indicates the end of the display block. For this reason, no embedded query language statements, host language statements, or comment lines can appear between the sections.
A display loop begins when the display block is encountered in the program's execution. At that time, the initialize section is executed, the form is displayed, and control is transferred from the program to the FRS. Control remains with the FRS until the user interrupts the FRS by selecting an operation, for example, a menu item. At that point, control transfers to the operation's activate section and the statements in that section are executed. Once the activate section has been executed, control returns to the FRS. When the user selects an operation that contains a statement to end the display, the finalize section is executed, the display loop ends, and control transfers from the FRS to the first statement in the program that follows the end of the display block.
Display loops can be nested; you can include a display block within an activate section of another display block. Thus your application can allow a user to call another form by selecting a menu item, for example. When the inner display loop ends, control passes back to the outer display loop and the original form reappears on the screen. A form can call a form that calls another form, and so on. The only restriction is that an already displayed form cannot be displayed again; that is, you cannot nest a display of the same form.
Last modified date: 08/14/2024