Understanding parallel dialogs

Parallel dialogs refers to the use of different declarative DIALOG blocks, in conjunction with the START DIALOG and TERMINATE DIALOG instructions, and an event loop using the fgl_eventLoop() built-in function, in order to control several forms simultaneously.

Important: This feature is only for mobile platforms.

Each dialog acts independently to control several elements of a window/form. During the execution of parallel dialogs, the user can switch to a window/form that is controlled by another running declarative DIALOG block. For more details about categories of dialogs, see Introducing dialogs.

The parallel dialog feature was introduced to implement mobile applications, where several forms can be accessed simultaneously, for example to get "split views" on mobile devices:


Form with split view screenshot (Android)

Figure 1. Form with Split View (Androidâ„¢)

A declarative dialog block is a module element defined at the same level as a FUNCTION or REPORT routine:

-- Module orders.4gl
SCHEMA stock
DEFINE arr DYNAMIC ARRAY OF RECORD LIKE orders.*
DIALOG orders_dlg()
  DEFINE x INT
  DISPLAY ARRAY arr TO sr_orders.*
     ...
  END DISPLAY 
END DIALOG

The name of a declarative dialog is mandatory. It can be referenced by a SUBDIALOG clause, by a START DIALOG and TERMINATE DIALOG instruction, and can identify sub-dialog actions with a prefix. Specifically, the name of the declarative dialog will be referenced in a START DIALOG and TERMINATE DIALOG instruction to implement parallel dialogs.

In terms of semantics, behavior and control block execution, a declarative dialog started with a START DIALOG instruction behaves like a procedural DIALOG block.

Important: Parallel dialogs implictly use the UNBUFFERED mode. It is not possible to change this mode when using parallel dialogs.

When using the DIALOG keyword inside a declarative dialog block to use ui.Dialog class methods, it references the current instance of the dialog object.

In order to execute parallel dialogs, you must implement a main interaction event loop, by using the fgl_eventLoop() built-in function. The minimal event loop code to implement is:
WHILE fgl_eventLoop()
END WHILE

Once the declarative dialogs and the interaction even loop are defined, it is possible to create the windows with OPEN WINDOW, and initiate the dialogs with the START DIALOG instruction.

If needed, show a given dialog window with the CURRENT WINDOW instruction. Additionally, (especially when implementing split views), you may want to "restart" a detail dialog, for example when selecting a new row in the main record list. To restart the detail dialog, execute TERMINATE DIALOG, followed by START DIALOG for the detail dialog. See split view programming for more details.

To finish a given dialog, execute the TERMINATE DIALOG instruction and close the dedicated window with CLOSE WINDOW window-name.

From a set of running parallel dialogs, it is possible to switch to a modal dialog by creating a dedicated window, and executing a procedural dialog instruction. When the procedural dialog is terminated, close the dedicated window, and the control will go back to the parallel dialog set.