Tech Tip: Using the * parameter with the DIALOG command
PRODUCT: 4D | VERSION: 15.x/14.x/13.x/12.x | PLATFORM: Mac & Win
Published On: October 19, 2016
An optional second parameter to the DIALOG command was added to 4D in v11SQL. This second parameter allows the developer to open additional non-modal windows in the same process.
The fact that the additional windows are in the same process reduces work and memory load on 4D. It reduces the need for additional processes and interprocess variables to do the same job. To make seamless use of the additional windows does require a little bit of ingenuity.
IMPORTANT: Everything is taking part in the same process but in different windows, so attention must be given on how to update the form variables in the additional windows.
The windows below are used to illustrate the points that need special attention.
The window on the left is the primary, or base, window that was opened at the initialization of the process. The window on the right is the additional, or external, window that was opened subsequent to the opening of the base window.
The external window is opened by the code shown above, note the addition of the "*" parameter.
When the external window opens the code in the form method, shown below, intializes the process variables needed to manipulate the form variables in the external window.
This code makes efficient use of Dynamic variables in the external window. They are not pre delcared so that they only consume memory once the window is opened. To address these undeclared variables, pointers are used in the task of assigning and updating data in these variables.
Regarding the code that empties any elements in the list box array. Because this is a process variable, if not done, the window can be closed and when reopened the data would still exist in the list box.
The use of the form event On Outside Call is critical for code execution in the context of the external window and not the base window.
The code above is in the object method for the "Message External Window" button. In this example the task is to add entries into the external window list box. The undeclared variable is named the defalult "Column1" but the pointer variable is given a discriptive name so that there is a positive ID of what is being addressed.
The code called from the "Message External Window" button is shown above. Becasue this code does not run in the external window it does not trigger a redraw event of the list box. To get the data to appear immediately in the list box, the command CALL PROCESS(Current process) is used to trigger the code contined in the "On Outside Call" form event of the external window, shown in the form method image, third from the top above.
To close the external window DO NOT use the command CLOSE WINDOW. It will not close an external window and will generate an error. Instead the commands CANCEL or ACCEPT must be used. The external window will automatically close when either command is invoked within the context of the external window.
If the process of the base window is terminated all external windows will automatically be closed.
The image below shows the contents of the list box after multiple clicks of the message button.