COMPANY

BLOGS

  • user warning: Unknown column 'u.signature_format' in 'field list' query: SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.signature_format, u.picture, u.data, c.thread, c.status FROM comments c INNER JOIN users u ON c.uid = u.uid WHERE c.nid = 20939 AND c.status = 0 ORDER BY c.cid LIMIT 0, 50 in /var/www/www.4d.com/docs/modules/comment/comment.module on line 991.
  • warning: file_get_contents(http://www.telize.com/geoip/54.81.210.99) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /var/www/www.4d.com/docs/includes/common.inc(1762) : eval()'d code on line 4.

The Star Trail: The Magic Dialog

13.11.2010
by Olivier Deschanels
Cirque

This is the first post in a series dedicated to stars. I'm not talking about stars making hits on the radio, but of the stars punctuating the 4D language that themselves often ensure real hits.

 

One of the latest stars to arrive is the one that proudly raises the DIALOG command as of version 11. This little star doesn't seem like much, but changes everything. In effect, it allows you to divide the execution cycle of a process into two parallel and simultaneous cycles.

 

 

When a form is opened with the DIALOG command via a line such as:

DIALOG("MyForm")

the line is executed and the dialog opens. The form opened in the dialog takes the execution cycle which allows it to bring to life form methods and object methods and to react to user actions.

 

 

When the dialog is closed (via the ACCEPT or CANCEL command) then the execution cycle returns to the line following the dialog command. When a form is opened with the DIALOG command accompanied by a star, the formula is opened in the dialog, and it has its own execution cycle giving it the ability to call a form method and method objects. But at the same time, the starred DIALOG command doesn't stop the execution cycle of the method that opened the dialogue, and the calling cycle continues its own life.

 

Take a look at the following code:

$refWindow1:=OpenFormWindow("MyPalette";window palette;on the left;at the top)
DIALOG("MyPalette";*)

$refWindow2:=OpenFormWindow([Client];"Input")
INPUT FORM([Client];"Input")
OUTPUT FORM([Client];"Output")
MODIFY SELECTION([Client])
CLOSE WINDOW($refWindow2)

In this code, the call to the command DIALOG opens a palette in its own window before the main window is opened itself to display the selection of records from the table [Client]. With this example, we get a screen with two simultaneous windows. These two windows are active at the same time, which is to say that the user can interact with the buttons and other interface objects where s/he sees fit.

 

 

Without using the star in the DIALOG command, the only way of arriving at the same result (from the user point of view) is to code two processes: One for the palette and another to display the selection, which is to say two processes at the same time communicate inter-process to exchange information. Effectively, in this case, clicking on a palette button should be announced to the display process of the selection via an update of variables (the SET PROCESS VARIABLE command) and an external call (the CALL PROCESS command). In short, there's nothing simple to implement if the 4D language provides you everything you need to do it.

 

 

Thanks to the star, we have two execution cycles but within the same process. And that is exactly where we find the "hit" offered by this star. Each execution cycle lives its own life but shares with the other the same context including, among others, the process variables, the current selections, everything... It's thus extremely simple to act on a displayed selection from a palette, because it's practically coded as if the form objects from one formula are present in the other.

 

It's interesting to note that the window opened for the palette isn't closed by the CLOSE WINDOW dialog. In effect it's not necessary, as following the opening by the DIALOG command as decorated by a star, the ACCEPT and CANCEL commands  take care of closing the window automatically.

 

We can thus guarantee that this star will allure you, leaving a mark in 4D's history!

RSS 0 comment(s) to this post