Where to run On Load?

Summary

I was wondering, when best to fill the content of a from. Obviously On load-event is the way to go. Alternatively, filling lengthy content in On Timer would first show the form and then fill the content. These days, 4D getting OS-native and 64-Bit, there is a third option CALL FORM. I ran all three options.

Habe ich ein aufwändig zu füllendes Formular, fülle ich die Werte nicht in On Load, sondern lagere die Befüllung in On Timer aus. Ab V15R5 kann ich die Aufgabe in CALL FORM auslagern. Der Anwender muß dann nicht Sekunden auf ein weißer Fensterrechteck gucken und sich wundern, ob was passiert.


Bisher

Blankes Fenster
Blankes Fenster
Wartend
Wartend

Üblicherweise starte ich ein Formular derart:
$winRef:=Open form window($formInput;Plain form window;Horizontally centered;Vertically centered;*)
DIALOG($formInput)
CLOSE WINDOW($winRef)

und führe dann im On Load-Form event die gesammelten Oberflächen-Einstellungen aus.
: (Form event=On Load)
Call_Tester („Event_Onload“)

Ich lagere die On Load-Aktivitäten gerne aus. Das hat den Vorteil, daß nicht eine weiße Fensterregion den Benutzer anstarrt, sondern ein Formular, wenn ich On Load so umschreibe:
: (Form event=On Load)
SET TIMER(1)
und in On Timer dann die Befüllung ausführe
: (Form event=On Timer)
SET TIMER(0)
Call_Tester („Event_Onload“)

Ab der V15R5

gibt es als weitere Option den Befehl CALL FORM, um die On Load-Phase auszulagern.

Dann verändert sich das Öffnen des Formulars um CALL FORM. Zuerst brauche ich die Fenster-ID und danach erst öffne ich den DIALOG.
$winRef:=Open form window($formInput;Plain form window;Horizontally centered;Vertically centered;*)
CALL FORM($winRef;Current method name;“Event_Onload“)
DIALOG($formInput)
CLOSE WINDOW($winRef)

Mein CALL FORM führt Call_Tester („Event_Onload“) aus, also das Gleiche wie in den Varianten mit On Timer und in On Load.

In einem Testformular lade ich 4.927 Banken über SELECTION TO ARRAY([BANKEN]BANK_BLZ;t_BLZ;[BANKEN]BANK_Name;t_BankName) in eine Array-Listbox. Hier die Ladezeiten der drei Varianten als Screenshots.

On Load
On Load braucht 3 Millisekunden
On Timer
On Timer braucht 118 Millisekunden
CALL FORM
CALL FORM braucht 9 Millisekunden

On Timer hat den größten Overhead, die beiden anderen bewegen sich in der gleichen Größenordnung. Nach CALL FORM wird die Formular-Methode nicht angestoßen. Die CALL FORM-Aufgabe muß auch alle Updates einschließen, wie das Delta ∆ der Aktion.



Currently

blanc screen
blanc screen
Waiting
Waiting

running a form uses this code:
$winRef:=Open form window($formInput;Plain form window;Horizontally centered;Vertically centered;*)
DIALOG($formInput)
CLOSE WINDOW($winRef)

the On Load-form event does all the work to fill the form-objects properly.
: (Form event=On Load)
Call_Tester („Event_Onload“)

I like to put all On Load-activities into a separate part of the code. This is to avoid having the user starring at the white window-rectangle, while loading. Then my On Load looks like this:
: (Form event=On Load)
SET TIMER(1)
und in On Timer does the work
: (Form event=On Timer)
SET TIMER(0)
Call_Tester („Event_Onload“)

Starting V15R5

there is another option to run the On Load-Phase separated loading the form: the command CALL FORM.

The code to run a form calls CALL FORM after receiving the window-ID and before opening the DIALOG.
$winRef:=Open form window($formInput;Plain form window;Horizontally centered;Vertically centered;*)
CALL FORM($winRef;Current method name;“Event_Onload“)
DIALOG($formInput)
CLOSE WINDOW($winRef)
In this example CALL FORM does call Call_Tester („Event_Onload“), which is the same code as used in both On Timer and On Load.

I made a simple test form filling 4.927 banks via SELECTION TO ARRAY([BANKEN]BANK_BLZ;t_BLZ;[BANKEN]BANK_Name;t_BankName) into an array-listbox. Check the screenshots to compare the milliseconds needed till the form is filled.

On Load
On Load needs 3 milliseconds
On Timer
On Timer needs 118 milliseconds
CALL FORM
CALL FORM needs 9 milliseconds

Obviously On Timer does have the biggest overhead, the other two being in the same ballpark. CALL FORM does not trigger the form-method to run. Therefore CALL FORM needs to update all data, like the delta ∆ of the action.