Parallel dialog programming steps

This procedure describes how to implement parallel dialogs with a declarative DIALOG block.

  1. 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).
  2. Create a dedicated .4gl module to implement the declarative DIALOG block.
  3. 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.
  4. 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).
    1. 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.
  5. Define a FUNCTION to create the dialog instance.
    1. 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.
    2. Fill the module variables (the data model) with data. For lists, you typically use a result set cursor.
    3. Start the dialog with the START DIALOG dialog-name instruction.
  6. Define a FUNCTION to terminate the dialog instance.
    1. In the function, finish the dialog with TERMINATE DIALOG dialog-name.
    2. Close the window dedicated to the dialog with CLOSE WINDOW window-name.
    3. If needed, free the data model (clear large program arrays) and database cursors, to save memory.
  7. 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.
  8. 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