This procedure describes how to implement parallel dialogs with a declarative
DIALOG block.
- Create a form specification file containing screen record(s) and/or screen array(s). The screen
records and screen arrays identify the presentation elements to be used by the runtime system to
display the data models (the content of program variables bound to the DIALOG
blocks).
-
Create a dedicated .4gl module to implement the declarative
DIALOG block.
-
With the DEFINE instruction, declare program variables
(records and arrays) that will be used as data models. These will typically be defined as
PRIVATE module variables. For record lists (DISPLAY ARRAY or
INPUT ARRAY), the members of the program array must correspond to the elements of
the screen array, by number and data types. To handle record lists, use dynamic arrays instead of
static arrays.
-
Define the declarative DIALOG block in the module, to handle
interaction. Define a sub-dialog with program variables to be used as data
models. The sub-dialog will define how variables will be used (display or
input).
-
Inside the sub-dialog instruction, define the behavior with control
blocks such as BEFORE ROW, AFTER ROW,
BEFORE FIELD, and interaction blocks such as
ON ACTION.
-
Define a FUNCTION to create the dialog instance.
-
Add a test to check if the window and form combination dedicated to the
dialog is already created, using ui.Window.forName(). If the window does not yet
exist, create it by using the OPEN WINDOW window-name WITH FORM
instruction. If the window exists, make it current with the CURRENT WINDOW IS
window-name instruction.
-
Fill the module variables (the data model) with data. For lists, you
typically use a result set cursor.
-
Start the dialog with the START DIALOG
dialog-name instruction.
- Define a FUNCTION to terminate the dialog instance.
-
In the function, finish the dialog with TERMINATE DIALOG
dialog-name.
-
Close the window dedicated to the dialog with CLOSE WINDOW
window-name.
-
If needed, free the data model (clear large program arrays) and
database cursors, to save memory.
-
If needed, add an ON ACTION close action handler to the
declarative dialog, that calls the terminate function. This allows the end user to close the
front-end window and stop the dialog.
-
In another module, implement the WHILE loop using the
fgl_eventLoop() built-in function to handle interaction events for parallel
dialogs. This module uses the start and terminate functions to control the individual dialog
modules.
The simplest form of the user interaction event loop
is:
WHILE fgl_eventLoop()
END WHILE